Qt-QProcess:启动外部程序失败
作者:互联网
使用QProcess启动外部exe文件:
1 QString exepath = QApplication::applicationDirPath() + "/Series/loads.exe"; 2 if (QFileInfo(exepath).exists()) 3 { 4 if (m_acouProcess == nullptr) 5 { 6 m_process = new QProcess(this); 7 } 8 m_process->start(exepath); 9 }
软件总是起不来,查资料发现是没有设置工作目录,加上下面两句就可以了:
1 QString workpath = QApplication::applicationDirPath() + "/Series"; 2 m_process->setWorkingDirectory(workpath);
标签:applicationDirPath,workpath,Qt,外部,QProcess,process,QString,exepath 来源: https://www.cnblogs.com/fengye2021/p/15362792.html