Reputation: 20986
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.
Upvotes: 9
Views: 8060
Reputation: 21
How about fromWinId https://doc-snapshots.qt.io/qt6-dev/qwindow.html#fromWinId
Creates a local representation of a window created by another process or by using native libraries below Qt.
Upvotes: 0
Reputation: 16933
Have you tried the QWinWidget
class from the Qt/MFC Migration Framework?
Upvotes: 6
Reputation: 3485
Use the create method of QWidget.
HWND main_window = ...
...
QWidget *w = new QWidget();
w->create((WinId)main_window);
Upvotes: 9