Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 606
Streight Avatar asked Jan 18 '23 13:01

Streight


1 Answers

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

like image 118
tibur Avatar answered Jan 22 '23 04:01

tibur