diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6329c52caa..cac5e72f39 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -377,16 +377,9 @@ void QApplicationPrivate::createEventDispatcher() */ QWidget *QApplication::topLevelAt(const QPoint &pos) { - QList<QScreen *> screens = QGuiApplication::screens(); - QList<QScreen *>::const_iterator screen = screens.constBegin(); - QList<QScreen *>::const_iterator end = screens.constEnd(); - - while (screen != end) { - if ((*screen)->geometry().contains(pos)) { - QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->handle()->topLevelAt(pos)); - return w ? w->widget() : 0; - } - ++screen; + if (const QWindow *window = QGuiApplication::topLevelAt(pos)) { + if (const QWidgetWindow *widgetWindow = qobject_cast<const QWidgetWindow *>(window)) + return widgetWindow->widget(); } return 0; } |