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

后端 未结 2 1603
半阙折子戏
半阙折子戏 2021-02-05 23:46

The Qt documentation gives this explanation:

  • QProcess::start:

    Starts the given program in a new process, if none is already

2条回答
  •  失恋的感觉
    2021-02-06 00:20

    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
    

提交回复
热议问题