开发者

After executing a shell script, the QT GUI is blocked

开发者 https://www.devze.com 2023-02-19 03:02 出处:网络
I have a GUI implemented with QT. The GUI has many buttons 开发者_开发技巧and one of them executes a shell script:

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");
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消