summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorSanthosh Kumar <santhosh.kumar.selvaraj@qt.io>2022-09-14 16:02:36 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-20 13:35:05 +0000
commit32b727864032ae84f4b203fa523fe2804d1eaa02 (patch)
tree910e8854f535f52453e31cec9032f9297ecdd294 /src/widgets/kernel/qwidget.cpp
parent70e33a585c13598a94b958bc3751952d4d1a6f21 (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 Change-Id: I4988eb72577fd557a328fd08bb09fa2fbded3138 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 82e7ac23a035a1c034d2ed665ecaeeb72914b715) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2cd30794cd..93e838d8b8 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);
+ }
}
/*!