问题描述
Qt文档给出了以下解释:
The Qt documentation gives this explanation:
-
QProcess :: start
:
QProcess :: startDetached
:
两者之间有什么区别?区别仅在于您可以使用 QProcess :: start
仅启动一个程序实例,而使用 QProcess :: startDetached
可以启动多个实例吗?
What is the difference between the two? Is the difference only that you can start just one instance of a program using QProcess::start
and many instances using QProcess::startDetached
?
推荐答案
如果使用 start
,则调用方进程的终止也将导致被调用进程的终止.如果使用 startDetached
,则在终止呼叫者之后,子代将继续存在.例如:
If you use start
, termination of the caller process will cause the termination of the called process as well. If you use startDetached
, after the caller is terminated, the child will continue to live. For example:
QProcess * p = new QProcess();
p->start("some-app");
delete p;// <---some-app will be terminated
QProcess * p = new QProcess();
p->startDetached("some-app");
delete p;// <---some-app will continue to live
这篇关于QProcess :: start和QProcess :: startDetached之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!