方案之一:
//启动进程
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;
评论 0
友善交流,让讨论变得更有价值。