c – QProcess :: start和QProcess :: startDetached之间有什么区别?

前端之家收集整理的这篇文章主要介绍了c – QProcess :: start和QProcess :: startDetached之间有什么区别?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Qt文档给出了这样的解释:

> QProcess :: start:

Starts the given program in a new process,if none is already running,
passing the command line arguments in arguments.

> QProcess :: startDetached:

Starts the program program with the arguments arguments in a new
process,and detaches from it.

两者有什么区别?区别的只是你可以使用QProcess :: start和使用QProcess :: startDetached的许多实例只启动一个程序实例吗?

解决方法

如果使用start,则调用者进程的终止也将导致被调用进程的终止.如果您使用startDetached,则在终止呼叫者后,该孩子将继续生活.例如:
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

猜你在找的C&C++相关文章