Den 28-12-2012 10:44, Bo Thorsen skrev:
[...] My goal now is just to call a windows specific function with the
HWND from a QWidget window. Something like this:
WindowsFunction(getHWND(myWidget));
If this is not possible in Qt 5 without bad hacks, then it's a problem
that needs to be adressed.
For future reference, this is the "solution" I came up with:
#include<5.0.0/QtGui/qpa/qplatformnativeinterface.h>
static QWindow* windowForWidget(const QWidget* widget) {
if (QWindow* window = widget->windowHandle()) {
return window;
}
if (const QWidget* nativeParent = widget->nativeParentWidget()) {
return nativeParent->windowHandle();
}
return 0;
}
HWND getHWNDForWidget(const QWidget* widget) {
if (QWindow* window = ::windowForWidget(widget)) {
if (window->handle()) {
return
static_cast<HWND>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("handle"),
window));
}
}
return 0;
}
This is pretty much a cut'n'paste from qapplication_p.h.
This sucks :(
Bo Thorsen.
--
Fionia Software - Qt experts for hire.
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest