)[%VS$YT67M8OUC{U328R~O.png (47.85 KB, 下载次数: 290)
pro = new QProcess();
pro->setProgram(fname);
pro->setWorkingDirectory(globals->gAppDataPath+"\\temp\\");
pro->setNativeArguments("命令行参数");//如果有命令行参数,可以这样
pro->setStandardInputFile(qApp->applicationDirPath().append("\\CMDRedirect.lst"));//如果有标准输入可以这样
connect(pro, SIGNAL(readyReadStandardOutput()), this, SLOT(on_cmdOutput()));
connect(pro, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(on_proc_finished(int, QProcess::ExitStatus)));
pro->start();
bOK = pro->waitForStarted(1000);
pro->waitForFinished(2000); //可以等2秒完成。也可以不等
void YourClass::on_cmdOutput(){
QString s(pro->readAllStandardOutput());
ui->textEditor->append(s);
}
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |