Home

QWinHost Class Reference

The QWinHost class provides an API to use native Win32 windows in Qt applications. More...

 #include <QWinHost>

Inherits QWidget.

Public Functions

Protected Functions

Additional Inherited Members


Detailed Description

The QWinHost class provides an API to use native Win32 windows in Qt applications.

QWinHost exists to provide a QWidget that can act as a parent for any native Win32 control. Since QWinHost is a proper QWidget, it can be used as a toplevel widget (e.g. 0 parent) or as a child of any other QWidget.

QWinHost integrates the native control into the Qt user interface, e.g. handles focus switches and laying out.

Applications moving to Qt may have custom Win32 controls that will take time to rewrite with Qt. Such applications can use these custom controls as children of QWinHost widgets. This allows the application's user interface to be replaced gradually.

When the QWinHost is destroyed, and the Win32 window hasn't been set with setWindow(), the window will also be destroyed.


Member Function Documentation

QWinHost::QWinHost ( QWidget * parent = 0, Qt::WFlags f = 0 )

Creates an instance of QWinHost. parent and f are passed on to the QWidget constructor. The widget has by default no background.

Warning: You cannot change the parent widget of the QWinHost instance after the native window has been created, i.e. do not call QWidget::setParent or move the QWinHost into a different layout.

QWinHost::~QWinHost ()

Destroys the QWinHost object. If the hosted Win32 window has not been set explicitly using setWindow() the window will be destroyed.

HWND QWinHost::createWindow ( HWND parent, HINSTANCE instance )   [virtual protected]

Reimplement this virtual function to create and return the native Win32 window. parent is the handle to this widget, and instance is the handle to the application instance. The returned HWND must be a child of the parent HWND.

The default implementation returns null. The window returned by a reimplementation of this function is owned by this QWinHost instance and will be destroyed in the destructor.

This function is called by the implementation of polish() if no window has been set explicitly using setWindow(). Call polish() to force this function to be called.

See also setWindow().

void QWinHost::setWindow ( HWND window )

Sets the native Win32 window to window. If window is not a child window of this widget, then it is reparented to become one. If window is not a child window (i.e. WS_OVERLAPPED is set), then this function does nothing.

The lifetime of the window handle will be managed by Windows, QWinHost does not call DestroyWindow. To verify that the handle is destroyed when expected, handle WM_DESTROY in the window procedure.

See also window() and createWindow().

HWND QWinHost::window () const

Returns the handle to the native Win32 window, or null if no window has been set or created yet.

See also setWindow() and createWindow().


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions