I am trying to convert a Qt4 Application to Qt5. The only thing I couldn\'t figure out is how to get the HWND of a Widget. The program uses EcWin7 to show the progr
#include
static QWindow* windowForWidget(const QWidget* widget)
{
QWindow* window = widget->windowHandle();
if (window)
return window;
const QWidget* nativeParent = widget->nativeParentWidget();
if (nativeParent)
return nativeParent->windowHandle();
return 0;
}
HWND getHWNDForWidget(const QWidget* widget)
{
QWindow* window = ::windowForWidget(widget);
if (window && window->handle())
{
QPlatformNativeInterface* interface = QGuiApplication::platformNativeInterface();
return static_cast(interface->nativeResourceForWindow(QByteArrayLiteral("handle"), window));
}
return 0;
}