[Qt-interest] When does QWidget have HWND?
william lee
welemon at gmail.com
Fri Feb 18 09:33:39 CET 2011
Hi,
I was using spy++ to check Qt application window, sometime I get the HWND
for each widget, like button, edit, combo etc. Sometime there isn’t HWND for
child widget at all.There is only a whole window HWND.
For example, Qt 4.6.1.
1. When you launch qtdemo’s browser project(QtWebKit demo browser),
you can use spy++ to check on it, there is only one parent window HWND. No
child window HWND, like menu bar, toolbar etc.
2. When you launch qtdemo’s Text Edit project, you can use spy++ to
check again, this time you will see every child window has HWND, including
menu bar, toolbar etc.
3. Another weird example is qtdemo’s SQL Browser project, when you
launch this application, it will pop up a dialog, “Connect…”. This Dialog is
for adding connections.
The first time launch this dialog(when app start, it will auto popup), you
use spy++ to check on it, there is only one HWND for whole dialog, no child
HWND.
But when you close it, and launch again from File->Add connection…, you can
use spy++ to check again, now it will have all child widget with HWND…
I googled, and find something about alien widget, I read this before. The
comments are like:
*Native Widgets vs Alien Widgets*
*Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing
system. They do not have a native window handle associated with them. This
feature significantly speeds up widget painting, resizing, and removes
flicker.*
*Should you require the old behavior with native windows, you can choose one
of the following options:*
1. *Use the **QT_USE_NATIVE_WINDOWS=1** in your environment.*
2. *Set the Qt::AA_NativeWindows<http://doc.qt.nokia.com/latest/qt.html#ApplicationAttribute-enum>attribute
on your application. All widgets will be native widgets.
*
3. *Set the Qt::WA_NativeWindow<http://doc.qt.nokia.com/latest/qt.html#WidgetAttribute-enum>attribute
on widgets: The widget itself and all of its ancestors will become
native (unless
Qt::WA_DontCreateNativeAncestors<http://doc.qt.nokia.com/latest/qt.html#WidgetAttribute-enum>is
set).
*
4. *Call QWidget::winId to enforce a native window (this implies 3).*
5. *Set the Qt::WA_PaintOnScreen<http://doc.qt.nokia.com/latest/qt.html#WidgetAttribute-enum>attribute
to enforce a native window (this implies 3).
*
* *
*http://doc.qt.nokia.com/latest/qwidget.html*
But I didn’t see any relative code in above three projects. Don’t know why
there is difference, especially for example 3, the same dialog can have
different behavior.
Can someone help me to explain it?
Thanks!
William L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110218/263cf986/attachment.html
More information about the Qt-interest-old
mailing list