Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Embed Windows program within Qt program
Hi, I am trying to embed a program that runs on windows (let's say Calculator) into my Qt program.
I already know how to launch it as an external program by running the following:
QProcess *proc = new QProcess(this); proc->start("C:\\Windows\\SysWOW64\\calc.exe");
But that only launches it as if I had launched the program manually from windows itself. I would like to have the program sit inside my Qt program and run within. It should also close and minimize along with the main Qt window.
I've been looking around online and I've come across this information: https://docs.huihoo.com/qt/solutions/4/qtwinmigrate/winmigrate-win32-in-qt-example.html
But I don't understand what I'm looking at there.
If someone could please explain how I can get this done I would greatly appreciate it!
JonB last edited by
This kind of question gets asked often. You can't actually "embed" an existing, external application into a Qt program/window (or anything else). Things have to be written to embed if the designers want it to embed.
The link you mention would allow a native Windows window to be used in a Qt app. But you can't make
calcrun it that window, so it doesn't help what you're looking for, I'm afraid.
What do you mean by a native Windows window? If all you mean is that I can host it inside without actually changing anything the external program does, that's fine. I don't need to change any of the workings of it.
JonB last edited by JonB
It gives you access to a Windows native window handle,
HWND, from your code.
QWinHost exists to provide a QWidget that can act as a parent for any native Win32 control.
Applications moving to Qt may have custom Win32 controls that will take time to rewrite with Qt. Such applications can use these custom controls as children of QWinHost widgets. This allows the application's user interface to be replaced gradually.
The Qt/MFC Migration Framework tool assists in the migration of existing Win32 or MFC applications to the Qt toolkit.
You don't have a Win32 control. You have an external application, with its own window. It's not interested in yours.
Did you notice that what you are looking at is from 2009...?
Ok, I think I get what you're saying now. Thanks for clearing that up for me!
There is a way to force an external window to become part of a widget, but the API isn't really meant to be used this way and there are multiple issues: https://bugreports.qt.io/browse/QTBUG-45275