PDA

View Full Version : QProcess starting minimized



moe
2nd March 2007, 10:08
Hi.

I'm using QProcess to start a process, with the static startDetached(...) method.
How can I make the started process minimized?


Thanks!

jpn
2nd March 2007, 10:21
Is the external program written by you? Maybe you could pass a command line parameter? QProcess does not know anything about possible windows created by the process.

moe
2nd March 2007, 10:28
Unfortunately I have little control over the process...

TheRonin
2nd March 2007, 15:17
Unfortunately I have little control over the process...

So you know of no command line features the process might have that you can exploit? What about input via standard input? If not, then, unfortunately, you might be out of luck. Of course, you _could_ use win32-api to minimize the window, but that might not be the cleanest solution and it's assuming you're coding on/for a windows platform.

Eldritch
3rd March 2007, 09:32
Assuming you're working in Windows, a quick check of the Qt source confirms that they don't support the mechanism that's available in the STARTUPINFO passed into the CreateProcess function down in QProcess' implementation.

Even if it did, that doesn't necessarily mean that the application will honor your request.

A general solution is going to be either insanely complex or simply full of holes. (Examples: app creates many windows; app creates window that can't be minimized; app creates a splashscreen, closes it and then creates main window, etc. etc. etc.) So, I'd say that in a Windows setup, just make your own CreateProcess() call and hope for the best.

Trying to ferret out the right window to minimize via an OS call is just an excercise in futilty.

IMO, it's a a valid suggestion to make to TrollTech to request such a feature to be available in QProcess, with the caveat that it may not work.

All that being said, unless you're truly shooting for a totally general-purpose utility here, having some a priori knowledge of what you're spawning and how to tell it to behave a certain way would be the most reliable solution.