L o a d i n g . . .
主打一个C++
文章详情

QT中启动新进程并等待结束后获取退出码与标准输出

Posted on 2021-08-05 09:26:44 by 主打一个C++

方案之一:

//启动进程
QProcess process;
process.start("./test.exe", QStringList() << "cmd");

// 等待进程结束
if (!process.waitForFinished()) {
        qDebug() << "Process did not finish in time.";
        return;
}

// 获取退出代码
int exitCode = process.exitCode();
qDebug() << "Process exited with code:" << exitCode;

// 获取进程的标准输出
QString output = process.readAllStandardOutput();
qDebug() << "Process output:" << output;


*转载请注明出处:原文链接:https://cpp.vin/page/102.html

作者近期文章
  • 随手笔记
  • 主打一个C++   2025-01-11 20:02:01
  • 都2000000025年了。还有不能随意访问guthub的,仔细看。在国内其实是可以正常访问的,gfw并没屏蔽。这里给出其中一个简单直接的方法稳定访问。1. 随便百度一个”dn
提示
×
确定
数据库执行: 8次 总耗时: 0.02s
页面加载耗时: 



wechat +447752296473
wechat cpp-blog