I'd like to embed a Qt Application inside Windows (not the other way around, as many other questions have already been answered). To clarify I have a win32 application which I launch a qt python process; this qt python process must be embedded within the win32 application. How can this be done? In the API for QWindow::fromWinId
, it clearly states:
"Creates a local representation of a window created by another process or by using native libraries below Qt...."
"...This can be used, on platforms which support it, to embed a QWindow inside a native window, or to embed a native window inside a QWindow."
And secondly QWidget::createWindowContainer
appears to only work for embedding native windows inside Qt (not the way I want it).
I am not sure how I would approach creating a QWidget
inside QWindow
. From this question, it seems the way would be to create a QQuickView
with a QWindow::fromWinId
; however, I can't seem to find how to bind a QWidget into a QQuickView.
Currently I am actually setting the parent with ::SetParent
but there are weird messaging protocols to deal with there so I'd like to try to refactor this with Qt's approach.
Some basic code written so far (PySide2, but C++ or any other language with Qt bindings is fine):
app = QApplication(sys.argv)
hwnd = int(sys.argv[1], 16)
nativeParentWindow = QWindow.fromWinId(hwnd)
quickview = QQuickView(nativeParentWindow)
# this part is incorrect (tries to embed native window into qt)
# I want this application to run embedded inside hwnd
wrongWidget = QWidget.createWindowContainer(quickview)
wrongWidget.show()
sys.exit(app.exec_())