You don't need a thread to run QProcess. It only makes things unnecessarily more complex. QProcess runs an external process, which doesn't block the main application anyhow unless you call one of the QProcess::wait*() methods (or QProcess::execute() which waits the process to finish). Instead, just start it and connect to its signals to get notified when something interesting happens:
connect(process,
SIGNAL(error
(QProcess::ProcessError)),
this,
SLOT(processError
(QProcess::ProcessError)));
connect(process,
SIGNAL(finished
(int,
QProcess::ExitStatus)),
this,
SLOT(processOutput
(int,
QProcess::ExitStatus)));
process->start("ComputerFortran");
void MyClass
::processError(QProcess::ProcessError error
) {
...
}
void MyClass
::processOutput(int exitCode,
QProcess::ExitStatus exitStatus
) {
....
}
process = new QProcess(this);
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processOutput(int, QProcess::ExitStatus)));
process->start("ComputerFortran");
void MyClass::processError(QProcess::ProcessError error)
{
...
}
void MyClass::processOutput(int exitCode, QProcess::ExitStatus exitStatus)
{
....
}
To copy to clipboard, switch view to plain text mode
Bookmarks