how to restart my own qt application?

后端 未结 8 1780
再見小時候
再見小時候 2020-11-30 09:39

i just asking myself how to restart my own qt application?

Can somebody please show me an example?

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 10:25

    Doing a real process restart without subclassing:

    QCoreApplication a(argc, argv);
    int returncode = a.exec();
    if (returncode == -1)
    {
      QProcess* proc = new QProcess();
      proc->start(QCoreApplication::applicationFilePath());
    }
    return returncode;
    

    Edit for Mac OS like earlier example.

    To restart call

    QCoreApplication::exit(-1);
    

    somewhere in your code.

提交回复
热议问题