diff options
-rw-r--r-- | src/winextras/qwineventfilter.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/winextras/qwineventfilter.cpp b/src/winextras/qwineventfilter.cpp index c04a9ed..a503f20 100644 --- a/src/winextras/qwineventfilter.cpp +++ b/src/winextras/qwineventfilter.cpp @@ -85,7 +85,7 @@ bool QWinEventFilter::nativeEventFilter(const QByteArray &, void *message, long if (event) { window = findWindow(msg->hwnd); if (window) - qApp->sendEvent(window, event); + QCoreApplication::sendEvent(window, event); delete event; } @@ -106,13 +106,10 @@ void QWinEventFilter::setup() QWindow *QWinEventFilter::findWindow(HWND handle) { - QWindow *w = 0; - QWindowList list = qApp->topLevelWindows(); - for (int i = 0; i < list.size(); i++) { - if (list.at(i)->winId() == reinterpret_cast<WId>(handle)) { - w = list.at(i); - break; - } + const WId wid = reinterpret_cast<WId>(handle); + foreach (QWindow *topLevel, QGuiApplication::topLevelWindows()) { + if (topLevel->handle() && topLevel->winId() == wid) + return topLevel; } - return w; + return Q_NULLPTR; } |