QProcess and shell : Destroyed while process is still running

前端 未结 2 930
忘掉有多难
忘掉有多难 2020-12-19 10:31

I want to launch a shell script with Qt.

QProcess process;
process.start(commandLine, QStringList() << confFile);
process.waitForFinished();

if(proces         


        
2条回答
  •  既然无缘
    2020-12-19 11:00

    Note you create QProcess into the local scope. This means that the object will be deleted when you exit the scope. In the destructor QProcess process terminates. The message "Destroyed" while "the process is still running" when the process terminates in the destructor.

    For solving this problem, you should call QProcess destructor when process is already terminated.

    If will be QProcess::waitForFinished(-1) into your example, it will occur, but this will block you application.

提交回复
热议问题