diff --git a/widgets/toolbutton.cpp b/widgets/toolbutton.cpp index d58368d59..9dfcf4d08 100644 --- a/widgets/toolbutton.cpp +++ b/widgets/toolbutton.cpp @@ -445,6 +445,17 @@ void ToolButton::changeEvent(QEvent *event) QGraphicsProxyWidget::changeEvent(event); } +QVariant ToolButton::itemChange(GraphicsItemChange change, const QVariant &value) +{ + //If the widget is hidden while it's hovered and then we show it again + //we have to disable the hover otherwise it will remain hovered. + if (change == ItemVisibleHasChanged){ + d->underMouse = false; + } + + return QGraphicsProxyWidget::itemChange(change, value); +} + QSizeF ToolButton::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const { QSizeF hint = QGraphicsProxyWidget::sizeHint(which, constraint); diff --git a/widgets/toolbutton.h b/widgets/toolbutton.h index 087da8034..6271f820a 100644 --- a/widgets/toolbutton.h +++ b/widgets/toolbutton.h @@ -183,6 +183,7 @@ protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void changeEvent(QEvent *event); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const; private slots: