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

Karol Krizka kkrizka at gmail.com
Wed Jun 3 07:31:24 CEST 2009


Hi,


On Wed, Jun 3, 2009 at 7:21 AM, Ross Bencina <rossb-lists at audiomulch.com> wrote:
> Hi!
>
> The docs for QWidget::winId() say:
> """Note: We recommend that you do not store this value as it is likely to
> change at run-time."""
>
> 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?
>
I'm doing something similar (using Irrlicht to render 3D stuff into a
QWidget), and I never had the winId change on me. However, I make sure
that I take the winId AFTER the widget has been show and the first
paintEvent has been sent. A year or two ago, I dug through the Qt code
and I think that I've found that the winId becomes stable after the
widget is shown. Are you by any chance grabbing the winId in a
constructor?

--
Cheers,
Karol Krizka
http://www.krizka.net




More information about the Qt-interest-old mailing list