Home

QWinHost Class Reference

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

#include <qwinhost.h>

List of all member functions.

Public Members

Protected 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, const char * name = 0, WFlags f = 0 )

Creates an instance of QWinHost. parent, name, and f are passed on to the QWidget constructor. The widget has a default backgroundMode of NoBackground.

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 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::polish ()

Calls createWindow() if no window has been set explicitly using setWindow().

This function is called by the Qt framework, and you should not normally need to call it yourself.

void QWinHost::setWindow ( HWND window )

Sets the native Win32 window to window. Any window created by a reimplementation of createWindow() is destroyed. Ownership of the window is not transferred to QWinHost, so it must be destroyed by the caller.

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().


This file is part of the Qt Solutions. Copyright © 2003-2004 Trolltech. All Rights Reserved.

Copyright © 2003-2004 TrolltechTrademarks
Qt Solutions