After executing a shell script, the QT GUI is blocked
I have a GUI implemented with QT. The GUI has many buttons 开发者_开发技巧and one of them executes a shell script:
system("/bin/sh executeScene.sh");
The script is executed properly but, the GUI is blocked until I close the script that was previously called. Is there a way to execute my shell script without blocking the GUI?
The GUI has another button to stop the shell script but, as the GUI is blocked, I cannot stop the script.
Use QProcess
to run the process asynchronously.
hye, i used this for one of my GUI applications...
void MainWindow::on_pushButton_clicked()
{
QProcess process;
process.startDetached("/bin/sh", QStringList()<< "/path/to/your/shell.sh");
}
精彩评论