Qt: How to catch an error with system call?

Viewed 1599

I am building a GUI application where I do a system call and call for gnuplot to run a script. Now i want to build in an error message that says when something is wrong (e.g. gnuplot is not installed or in the wrong path).

So I've been thinking about just putting out a QMessageBox, but I don't know how I can check whether the system call succeeded or not.

if(//System call didn't work)
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Error");
    msgBox.setIcon(QMessageBox::Critical);
    msgBox.setText("GNUPLOT was not installed");
    msgBox.exec();
}

My system call looks like this:

system(gnuplot script.txt);

Any suggestions?

1 Answers
Related