How to create a QWidget with a HWND as parent?

Anders Sandvig picture Anders Sandvig · Nov 16, 2008 · Viewed 7.3k times · Source

With wxWidgets I use the following code:

HWND main_window = ...
...
wxWindow *w = new wxWindow();
wxWindow *window = w->CreateWindowFromHWND(0, (WXHWND) main_window);

How do I do the same thing in Qt? The HWND is the handle of the window I want as the parent window for the new QtWidget.

Answer

sep picture sep · Nov 16, 2008

Use the create method of QWidget.

HWND main_window = ...
...
QWidget *w = new QWidget();
w->create((WinId)main_window);