Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to restart my own qt application?

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

Can somebody please show me an example?

like image 879
Klaus Avatar asked Feb 26 '11 21:02

Klaus


People also ask

How does Qt application work?

Qt uses a command line tool that parses these project files in order to generate "makefiles", files that are used by compilers to build an application. This tool is called qmake. But, we shouldn't bother too much about qmake, since Qt Creator will do the job for us. TEMPLATE describes the type to build.


2 Answers

To restart application, try:

#include <QApplication> #include <QProcess>  ...  // restart: qApp->quit(); QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); 
like image 75
masoud Avatar answered Oct 14 '22 09:10

masoud


I'm taking the other answers solutions, but better. No need for pointers, but there is a need for a ; after the while statement of a do { ... } while( ... ); construct.

int main(int argc, char *argv[]) {     const int RESTART_CODE = 1000;      do     {         QApplication app(argc, argv);         MainWindow main_window(app);     } while( app.exec() == RESTART_CODE);      return return_from_event_loop_code; } 
like image 29
rubenvb Avatar answered Oct 14 '22 07:10

rubenvb