QProcess process; QString program = "/path/to/myProgram"; if (!process.isRunning()) { process.start(program); }
QProcess process; QString program = "/path/to/myProgram"; process.start(program); while (process.isRunning()) { // do some other work while waiting for process to finish } // process has now finished, take action accordingly if (process.exitStatus() == QProcess::NormalExit) { // process completed successfully } else { // process exited with an error }In both examples, we can see that the isRunning() method is called on a QProcess object to determine whether the referenced process is running or not. The Qt library (package) provides the QProcess class for working with external processes.