PDA

View Full Version : How to detect a QProcess is started



cooler123
20th June 2008, 09:04
I start the process A before my main application starts using startDetached of QProcess.
However I having problem of the main application lose focus to process A.
I have try to set back focus to main application, however the process A is actually show up slower than the main application. So, my code of set focus will finish run even before process A runs finished and get the focus.

How to actually detect when process A is started? When process A start up it only shows as system tray icon.

^NyAw^
20th June 2008, 09:20
Hi,

Take a look at QProcess::finished signal

cooler123
20th June 2008, 10:53
Oops, my mistake.
I actually need to know when the process A actually started and not finished running.

mazurekwrc
20th June 2008, 11:13
maybe stateChanged ( QProcess::ProcessState newState ) (http://doc.trolltech.com/4.4/qprocess.html#stateChanged) signal will help you ?

cooler123
20th June 2008, 11:24
I use startDetached to start the process that will not affect my main application.
I have try all the signal, started, finished, stateChanged... all also not working. No signal is returned.

jacek
22nd June 2008, 23:34
I use startDetached to start the process that will not affect my main application.
I have try all the signal, started, finished, stateChanged... all also not working. No signal is returned.
QProcess::startDetached() is a static method, so there is no QProcess object you can connect to to receive the signal from. Use QProcess::start() instead.

cooler123
23rd June 2008, 03:35
After i use start() to start the process, can I detached it after that?

jacek
24th June 2008, 23:07
After i use start() to start the process, can I detached it after that?
No, you can't. QProcess will kill its child processes. Maybe you could someway determine the state of child process if you had its PID?

The Storm
25th June 2008, 18:43
Why you need to detach the child process? If you don't call the waitForFinished() function the child process will not block your application and you will be able to monitor it well. :)

mcosta
26th June 2008, 10:45
The QProcess:startDetached function returns TRUE on success and set pid argument