summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/kernel/qapplication_p.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 30d5e4400d..0da36f9262 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -350,11 +350,23 @@ public:
QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
bool spontaneous = true);
void sendSyntheticEnterLeave(QWidget *widget);
+
+ static QWindow *windowForWidget(const QWidget *widget)
+ {
+ if (QWindow *window = widget->windowHandle())
+ return window;
+ if (const QWidget *nativeParent = widget->nativeParentWidget())
+ return nativeParent->windowHandle();
+ return 0;
+ }
+
#ifdef Q_OS_WIN
- static HWND getHWNDForWidget(QWidget *widget)
+ static HWND getHWNDForWidget(const QWidget *widget)
{
- QWindow *window = widget->windowHandle();
- return static_cast<HWND> (QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window));
+ if (QWindow *window = windowForWidget(widget))
+ return static_cast<HWND> (QGuiApplication::platformNativeInterface()->
+ nativeResourceForWindow(QByteArrayLiteral("handle"), window));
+ return 0;
}
#endif