[Qt-interest] is it possible to get a non-changing winId?

Denis Dzyubenko denis.dzyubenko at trolltech.com
Wed Jun 3 13:00:07 CEST 2009


Hi,

Ross Bencina wrote:
> I am on MS Windows, and trying to use a QWidget to host a 3rd-party plugin 
> which needs a parent HWND. This has been working mostly but one plugin 
> author is reporting that the HWND which I get from QWidget::winId()  is 
> becoming invalid (so I guess this is in line with the Qt documentation).
> 
> My question is: is there any way to stop Qt reallocating the HWND and get it 
> to keep the same HWND for the entire life of the QWidget? Is there any other 
> way I can integrate a standard windows handle into Qt? Would WA_NativeWindow 
> help?

setting WA_NativeWindow attribute makes sure that the widget will have a 
native window id (instead of using being non-native ("alien") and 
drawing itself on it's toplevel window id).

However winId() shouldn't change unless you reparent a widget, or 
hide/show it several times.

In worst case you can try create a native window id manually and attach 
it to QWidget with a QWidget::create() function.

-- 
Denis Dzyubenko
Software Engineer
Nokia, Qt Software



More information about the Qt-interest-old mailing list