diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2cd30794cda..93e838d8b82 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 childList = children; for (int i = 0; i < childList.size(); ++i) { QWidget *widget = qobject_cast(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); + } } /*!