PyQt5 application not restarting itself
Solved
General and Desktop
-
So I followed this documentation
https://wiki.qt.io/How_to_make_an_Application_restartableI need to make my software restart after doing some updates but it exists successfully but then doesn't start up anymore.
My code looks like this:
def restart(self): qApp.exit(-123456789)
Note: The function is inside the Main class which inherits from QMainWindow
-
did you really follow that documentation? There is nothing magical about the exit code. you have to check it as a loop condition in main. I don't see enough of your code to know whether you did that.
-
Since python does not have a do while loop, here's something I tried
if __name__ == '__main__': app = QApplication(sys.argv) current_exit_code = 0 while True: ex = Main() ex.setFont(QFont("Consolas", 10)) ex.setStyleSheet(blue) #welcome = Welcome(ex) ex.showMaximized() current_exit_code = app.exec() if current_exit_code == -123456789: break
That didn't work either
-
reread the documentation you referenced above. You should instantiate QApplication inside your while loop, not outside.