From f547381806f6251c176e587d6d95b66bb8dfa88c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Jul 2014 09:09:16 +0200 Subject: Implement QApplication::topLevelAt() using QGuiApplication::topLevelAt(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reducing code duplication, preparing for High-DPI support. Task-number: QTBUG-38858 Change-Id: Id0ed12db4b5cadd0eef79afd0ac62f58a7b01901 Reviewed-by: Jørgen Lind --- src/widgets/kernel/qapplication.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/widgets') 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 screens = QGuiApplication::screens(); - QList::const_iterator screen = screens.constBegin(); - QList::const_iterator end = screens.constEnd(); - - while (screen != end) { - if ((*screen)->geometry().contains(pos)) { - QWidgetWindow *w = qobject_cast((*screen)->handle()->topLevelAt(pos)); - return w ? w->widget() : 0; - } - ++screen; + if (const QWindow *window = QGuiApplication::topLevelAt(pos)) { + if (const QWidgetWindow *widgetWindow = qobject_cast(window)) + return widgetWindow->widget(); } return 0; } -- cgit v1.2.3