Streight Streight - 1 month ago 6
C++ Question

How to get the error code from a QProcess?

I have a function

A()
in which I execute eight other 'sub-functions' which all include a
QProcess
. How do I get the return codes from all the QProcesses?

Example:

void Mainclass::A()
{
B();
C();
// ...
I();
}

void Mainclass::B()
{
QString CommandPath = "PathB";
QProcess *Process = new QProcess(this);

Process->setWorkingDirectory(MainDir);
Process->setStandardOutputFile(MainDir + "/geometries");
Process->start(CommandPath);
Process->waitForFinished();
QProcess::ExitStatus Status = Process->exitStatus();

if (Status == 0)
{
std::cout << "App executed!" << std::endl;
}
}


I found this example but don't understand how to implement it myself because I use pointer objects in my application.

Answer

Maybe int QProcess::exitCode () const? See.

Comments