基本思路
- Qt中的類
支援在程式中另外開辟線程QProcess
- 其中
方法支援以字元串為參數執行指令start
///
/// \brief MainWindow::cmdLine run a linux command with string format in the bash
/// \param strCmd linux command in string format
///
void MainWindow::cmdLine(QString strCmd)
{
QProcess process;
process.start("bash",QStringList() << "-c" << strCmd);
process.waitForFinished();
process.close();
}
- 但該指令看不到執行過程
終端執行
- 可以下述方式調用該函數,建立終端執行腳本
QString strCmd = QString("gnome-terminal -x bash -c \"sh Run.sh run %1 %2 %3;\"")
.arg(this->vecPoint.size())
.arg((int)(this->raleMapWidth))
.arg((int)(this->raleMapHeight));
this->cmdLine(strCmd);
- 即運作時會彈出終端視窗,檢視腳本的标準輸出
參考内容
- 單條指令執行
https://www.cnblogs.com/xupeidong/p/11777031.html
- 單條指令以及外部腳本執行
https://blog.csdn.net/lusanshui/article/details/88720494
- 單條指令以及外部腳本執行
https://www.cnblogs.com/xupeidong/p/9317841.html
更多内容
-
語雀
https://www.yuque.com/wangxi_chn
【Qt】執行腳本基本思路終端執行參考内容更多内容 【Qt】執行腳本基本思路終端執行參考内容更多内容