How to embed external application in a scalable Qt window?
-
I'm using Qt5.2 and for the purposes of this topic, we care about Windows only.
I have a pre-existing Windows application which runs at a fixed 1280x1024 (it's that fixed side because it controls external hardware and has a completely "owner drawn" interface without any windows chrome)
I now have a new Qt application that can launch this pre-existing app as a process. To do this I use QProcess::execute(..) and then QProcess::startDetached(..)
That works fine to get the app open, at 1280x1024 externally, but I'm interested in finding a way to take the window of the spawned EXE and instead render it inside a Qt widget such that the whole 1280x1024 application will scale to display at whatever size the user makes the form (up to a max of 1280x1024). The "embedded" EXE process should continue to receive mouse-events so the user can still interact with it.
I hope I've described this well. Is this possible with Qt?
Thanks!
-
I think there is a way:
You can embed windows/widgets with "QWidget::createWindowContainer":http://qt-project.org/doc/qt-5/qwidget.html#createWindowContainer . That's a static function that returns a QWidget - but it expects a QWindow*."QWindow::fromWinId":http://qt-project.org/doc/qt-5/qwindow.html#fromWinId
Now this function returns a QWindow* and only takes a platform-specific WinId, but you have to take care of two things: You have to obtain the WinId (maybe your QProcess can help, I don't know much about Windows internals), and, according to the documentation, a WinId can change during runtime, but as it says "here":http://qt-project.org/doc/qt-5/qwidget.html#winId you could probably counteract that.I think with some work and reading this should be possible. If you succeed or need more help, please say so. :)