What is the difference between QProcess::start and QProcess::startDetached?

孤人 提交于 2019-12-03 03:10:17
SingerOfTheFall

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

The start() function is a member function, while startDetached is a static class function.

If you look at the documentation of QProcess, you'll see that there are functions to allow you to do things with the process such as: -

These are just some of the things that you can only do with an instance of a QProcess. If, however, you want a simple and quick way of starting a process without having to create an instance and you don't need the extra functionality, you can simply call QProcess::startDetached.

Also, as the docs state for startDetached: -

If the calling process exits, the detached process will continue to live.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!