使用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);