2018年3月21日11:14:11
原因
根据文档说明,QProcess启动子进程后必须调用对应的方法等待子进程完成启动并等待子进程有数据可读,才能进行读取,否则读取得到的内容为string::empty
解决
if (apInstance->waitForStarted(-1)) {while(apInstance->waitForReadyRead(-1)) {qDebug() << apInstance->readAllStandardOutput();}
}
在读取子进程标准输入输出之前必须进行等待,否则可能读取得到空的内容或丢失部分信息。