1
2
3
4
5
6
7
8
9
10
11
12
#include <QProcess>

QProcess pCmd = new QProcess(this);
connect(pCmd , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
connect(pCmd , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));

pCmd->start("bash");
pCmd->waitForStarted();

QString strTermCmd = "git add -A" + '\n';
pCmd->write(strTermCmd.toUtf8().data());
pCmd->waitForFinished();

问题的关键就在这个pCmd->start("bash");