I’m writing desktop application in QT.
In my application I’m openening another application by the class
QProcess *myProcess;
myProcess->start(path + argStr);
i would like to get indication if the process is close( maybe by someone manullay)
so i start a new thread
void processExitDetector::run()
{
connect(myProcess,SIGNAL(finished(int)),this, SLOT (stop()));
}
void processExitDetector::stop()
{
}
but if have breakpoing in the function stop(). i never stop there, even if i’m stopping the process.
what i’m doing worng? what the best way to get indication when the process stopped?
I think you might have the concept of SIGNAL/SLOT a bit backwards. You don’t need to wait for the exit of the QProcess in a thread to make the connection. Its the connection of the signal to to the slot that should be telling you when its done.
You have the right idea with QProcess.finished(), but there is no need to start a thread solely to block on
waitForFinished. Basically the connection you are making is pointless.processFinished()is just the SLOT you have defined (or using a built in SLOT) to be notified when your process is done.