标签:
在QT中经常要调用外部命令或者是执行shell脚本,并且要对执行结果进行分析。
QProcess runShellProcess =new QProcess(this); //调用过程输出的监控 connect(runShellProcess, SIGNAL(readyRead()), this, SLOT(readProcess())); connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess()));
然后在readProcess()和finishedProcess()中进行分析
void MainWindow::executeShellQProcess(const char *shell){ shellOutput=""; runShellProcess->start(shell); } void MainWindow::readProcess(){ QString output=runShellProcess->readAll(); shellOutput+=output; //do something } void MainWindow::finishedProcess(){ qDebug()<<shellOutput; //do something }
标签:
原文地址:http://www.cnblogs.com/shinf/p/4898389.html