[英]How to create a QWidget with a HWND as parent?
With wxWidgets I use the following code:使用 wxWidgets 我使用以下代码:
HWND main_window = ...
...
wxWindow *w = new wxWindow();
wxWindow *window = w->CreateWindowFromHWND(0, (WXHWND) main_window);
How do I do the same thing in Qt?我如何在 Qt 中做同样的事情? The HWND
is the handle of the window I want as the parent window for the new QtWidget. HWND
是我想要作为新 QtWidget 的父窗口的窗口的句柄。
Use the create method of QWidget. 使用QWidget的create方法。
HWND main_window = ...
...
QWidget *w = new QWidget();
w->create((WinId)main_window);
您是否尝试过Qt / MFC迁移框架中的QWinWidget
类?
How about fromWinId https://doc-snapshots.qt.io/qt6-dev/qwindow.html#fromWinId 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.创建由另一个进程或使用 Qt 下的本机库创建的窗口的本地表示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.