- //方式1 需要主函数中事件循环判断 //qApp->exit(773); //重启代码,773 = 'r'+'e'+'s'+'t'+'a'+'r'+'t' ==>restart
//方式2 直接重启 // #ifdef Q_OS_WIN qApp->closeAllWindows();
QProcess::startDetached(qApp->applicationFilePath(), QStringList()); exit(0);
#elif defined (Q_OS_LINUX) qApp->closeAllWindows();
QProcess::startDetached(qApp->applicationFilePath(), QStringList("-qws"));
QProcess::execute("-qws"); //经测试linux下需要这样,软件才能运行 #endif
QT实现软件重启原著者
|