[Interest] Qt5.1, Get "HWND" from "QWidget" ?
Friedemann Kleint
Friedemann.Kleint at digia.com
Wed Jun 26 09:54:05 CEST 2013
Hi,
the "official" solution is:
Add QT += gui-private to your project and use:
#include <QWindow>
#include <qpa/qplatformnativeinterface.h>
widget->show();
if (const QWindow *w = widget->windowHandle()) {
HWND hwnd =
(HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("handle"),
w);
This requires the window to be visible (underlying native window must
exist).
Inofficially, (HWND)widget->winId(); still works, note that it enforces
the creation of a native window, though.
Regards,
Friedemann
--
Friedemann Kleint
Digia, Qt
More information about the Interest
mailing list