how to restart my own qt application ?
Restart my own qt appliactions:
#include <QApplication> #include <QProcess> ... // restart: qApp->quit(); QProcess::startDetached(qApp->arguments()[0], qApp->arguments())
Here the solution is:
The qt applications are ; after the while statement of a do { … } while( … ); .
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; }
Alternative code is:
main.cxx int main(int argc, char * argv[]) { int result = 0; do { QCoreApplication coreapp(argc, argv); MyClass myObj; result = coreapp.exec(); } while( result == 1337 ); return result; }
Class.cxx
qApp->exit(1337);