[Interest] Convert WId to HWND

Bo Thorsen bo at fioniasoftware.dk
Fri Dec 28 10:44:53 CET 2012


Hi Sean,

Den 20-12-2012 13:30, Sean Harmer skrev:
> On Thursday 20 December 2012 12:11:43 Bo Thorsen wrote:
>> In Qt4, WId was a platform independent window handle. On Windows this
>> was just a typedef from HWND. But in Qt5, that's no longer the case.
> Take a look at:
>
> virtual QPlatformNativeInterface *QWindowsIntegrationnativeInterface() const

QPlatformNativeInterface is a private class. Yes, it's nice for 
inspiration, but I'm pretty amazed at how difficult this is with Qt 5. I 
find it hard to believe that it's so hard to get to the HWND.

> and
>
> void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray
> &resource, QWindow *window)
>
> in src/plugins/windows. With the QWindowsNativeInterface you can obtain the
> native HWND and device context I think.

ATM it looks like I pretty much have to copy the entire source code for 
all the HWND access, just to get to the HWND from a widget. That sucks :(

Right now, I have given up on a platform independent way to store window 
handles. 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.

I'm still hoping that I just missed the proper solution.

Bo Thorsen.

-- 
Fionia Software - Qt experts for hire.




More information about the Interest mailing list