diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-09-14 16:02:36 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-20 10:34:08 +0000 |
commit | 82e7ac23a035a1c034d2ed665ecaeeb72914b715 (patch) | |
tree | 354dc69515992da8c7d965fcd27a2ab342c1a88f /src/widgets | |
parent | 013c346a8dcbd618febb07884c64c740daf9754d (diff) |
Clear WA_UnderMouse attribute when widget gets hidden
From 6.3 onward, hiding a widget doesn't automatically clear
QT::WA_UnderMouse attribute.
This leads to multiple buttons drawn with highlighted rectangle at the
same time (refer bug). The behavior is observed after
commit 0246bfd40a2cc5ea9cfc035146e6dd865b334c68 made as part of
bug QTBUG-53286.
This patch clears WA_UnderMouse attribute in widget hideChildren() and
subsequently, widgets that are hidden will not inherit this attribute
on the next show operation.
The attribute will be set only when the widget is under mouse cursor.
Fixes: QTBUG-104805
Pick-to: 6.4
Change-Id: I4988eb72577fd557a328fd08bb09fa2fbded3138
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index fa6915e545..202750d659 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8339,6 +8339,7 @@ void QWidgetPrivate::showChildren(bool spontaneous) void QWidgetPrivate::hideChildren(bool spontaneous) { + Q_Q(QWidget); QList<QObject*> childList = children; for (int i = 0; i < childList.size(); ++i) { QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); @@ -8370,6 +8371,14 @@ void QWidgetPrivate::hideChildren(bool spontaneous) } #endif } + + // If the window of this widget is not closed, then the leave event + // will eventually handle the widget under mouse use case. + // Otherwise, we need to explicitly handle it here. + if (QWidget* widgetWindow = q->window(); + widgetWindow && widgetWindow->data->is_closing) { + q->setAttribute(Qt::WA_UnderMouse, false); + } } /*! |