c++ - 如何从 QProcess 获取错误代码?

标签 c++ qt qt-creator qprocess

我有一个函数 A(),我在其中执行其他八个“子函数”,它们都包含一个 QProcess。如何从所有 QProcesses 获取返回码?

例子:

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;
    }
}

我找到了 this example但我自己不明白如何实现它,因为我在我的应用程序中使用了指针对象。

最佳答案

也许 int QProcess::exitCode () constSee .

关于c++ - 如何从 QProcess 获取错误代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9136081/

相关文章:

c++ - String At 函数运行时错误

qt - QtCreator 自定义向导中的项目变量和配置

c++ - 如何在 C++ 中手动初始化 std::list 的对象? class的指针有member list<>,不能new怎么办?

c++ - Windows 7 64位/Visual Studio 2008/OpenCV2.1错误: "The application was unable to start correctly (0xhex).."

c++ - QPixmap fromImage 导致分割错误

c++ - 通过 QT Creator 以 snake case 形式生成重构方法

c++ - 是否可以获取内置标准运算符的函数指针?

c++ - Qt - QStackedWidget 用法

c++ - Qt 从 Mainwindow 字段中的 Mainwindow 获取 ui 参数

c++ - 带有 std::vector 的信号和槽:左值问题