头文件包含
#include <QProcess>
示例代码
QProcess p;
QString command = "git --help";
p.start(command);
p.waitForStarted();
p.closeWriteChannel(); //关闭写通道 ,解决未响应问题
p.waitForFinished();
QString OutMsg = QString::fromLocal8Bit(p.readAllStandardOutput());
QString ErrMsg = QString::fromLocal8Bit(p.readAllStandardError());
假如调用outArea和errArea显示两个流的字符串
ui->outArea->setText(OutMsg);
ui->errArea->setText(ErrMsg);