QProcess :: start和QProcess :: startDetached之间有什么区别? [英] What is the difference between QProcess::start and QProcess::startDetached?
问题描述
Qt文档给出了以下解释:
The Qt documentation gives this explanation:
-
QProcess :: start
:
如果没有程序在运行,则以新进程启动给定程序,在参数中传递命令行参数.
Starts the given program in a new process, if none is already running, passing the command line arguments in arguments.
QProcess :: startDetached
:
使用新的arguments参数启动程序过程,并从中分离出来.
Starts the program program with the arguments arguments in a new process, and detaches from it.
两者之间有什么区别?区别仅在于您可以使用 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之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!