View Single Post
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#10
Originally Posted by Copernicus View Post
Ah! So a "StartDetached()" call would work in that case, allowing the script to continue after the QProcess object is destroyed.

Actually, this also means you don't really need the "kill.sh" script to stop the process (unless kill.sh does something special). A call to "terminate()" (or just destroying the object) should do the trick...
startDetached() will work, yes, because it's a static method. The disadvantage is that you don't have access to the QProcess object after the method is called. Another alternative is to call waitForFinished() after calling start(), which enables synchronous (blocking) use of QProcess. That way you can use a QProcess object with local scope, because there is no further event processing until the start() method returns. This approach has the disadvantage of blocking the main thread until the program called by QProcess exits. Synchronous use of QProcess is really only useful for cases where there is no event loop. I can't see any reason to use it where you have a QApplication instance.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2012-10-20 at 00:00.
 

The Following 3 Users Say Thank You to marxian For This Useful Post: