//重启软件 void MainWindow::on_pushButton_UI_reboot_clicked()

{ //方式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 }

相关文章:

  • 2021-07-20
  • 2022-12-23
  • 2021-10-11
  • 2021-04-11
  • 2021-10-05
  • 2022-02-08
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案