PDA

View Full Version : How run Windows QProcess Window inside QWidget



aguayro
5th April 2015, 03:25
I need use a QProcess to open an external exe file, and show that window without titlebar and with a selected size.
I'm not sure how achieve this, maybe running the external application inside a QWidget that I can control?
I supose Qt can't control the QProcess window size and titlebar in Windows, so I hope there is some way to do this, is very important for my application.
Any help with this problem please?
I want to add a frame (bezel) around the external application, is the final objetive, like this image:

11060

jefftee
5th April 2015, 03:58
QProcess does not provide a way for you to do what you want. You can launch the program using QProcess, but no way to wrap its GUI inside of a Qt Widget that I'm aware of.

anda_skoa
5th April 2015, 08:58
You will need platform specific APIs for some of that.

One thing you need to get is the platform's native window handle for the other program, then you can use QWindow::fromWinId() to wrap it in QWindow, which you can then embed in a widget using QWidget::createWindowContainer().

That is all Qt can do for you there, your other objectives might or might not be possible depending on the native API.

Cheers,
_

aguayro
5th April 2015, 13:17
thanks both for the answers, I done it with (this hide the titlebar for example) :


HWND hWnd = FindWindow(L"KegaClass", NULL);

LONG_PTR lStyle = ::GetWindowLongPtr(hWnd, GWL_STYLE);
lStyle &= ~WS_CAPTION;
::SetWindowLongPtr(hWnd, GWL_STYLE, lStyle);

qDebug() << hWnd;

But i still have a question, theres is a way to get the Windows HWND from a qProcess?
I'd like to get the Windows HWND from the QProcess I start in my aplication when I launch it.

anda_skoa
5th April 2015, 14:10
QProcess doesn't know anything about the child process' internals, e.g. whether it has UI at all or if it has which windows it uses.
The only thing it knows it the process ID.

Maybe your platform native API provides functions to query for UI resources such as windows given the process ID.

Cheers,
_

aguayro
5th April 2015, 15:44
Yeah, ti's solved, thanks a lot for the directions :)

I've used EnumWindows form windows api and QProcess::pid(), hope can help somebody in the future.

shame
25th June 2015, 09:53
Example please:rolleyes: