简体   繁体   English

关闭qt应用程序时,要杀死qprocess

[英]when closing the qt application, want to kill qprocess

in my mainwindow.cpp, inside the constructor, I started a qprocess so the process(.exe) runs when I open the qt application. 在我的mainwindow.cpp中,在构造函数中,我启动了一个qprocess,因此当我打开qt应用程序时,process(.exe)运行。

Now I want to kill/close the qprocess when I close the qt application. 现在,我想在关闭qt应用程序时终止/关闭qprocess。 How can I do it? 我该怎么做?

See the documentation for QProcess::terminate and QProcess::kill . 请参阅QProcess::terminateQProcess::kill的文档。 They each have slightly different behavior. 它们各自的行为略有不同。 Use terminate to give the process a chance to shut down gracefully. 使用terminate使进程有机会正常关闭。 Use kill to kill it more forcefully. 使用kill可以更有力地杀死它。 In the case of terminate , you probably want to wait until the child process has finished (eg QProcess::waitForFinished ) before exiting the parent process. terminate的情况下,您可能要等到子进程完成(例如QProcess::waitForFinished ),然后退出父进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM