我正在使用PySide,并寻求一种方式来重新启动我的Qt应用程序。这取决于python,还是必须由Qt控制?什么是重新启动QApplication的正确方法?
BY ROSTYSLAV的建议贝洛:
class MyAppMainWindow(QMainWindow):
def __init__(self):
self.EXIT_CODE_REBOOT = -15123123
exit_code = self.EXIT_CODE_REBOOT
def slotReboot(self):
print "Performing application reboot.."
qApp.exit(self.EXIT_CODE_REBOOT)
def main():
currentExitCode = 0
app = QApplication(sys.argv)
ex = MyAppMainWindow()
while currentExitCode == ex.EXIT_CODE_REBOOT :
currentExitCode = app.exec_()
return currentExitCode
if __name__ == '__main__':
main()
很显然,我没有完全理解。请求帮助。
我编辑了带有建议代码的问题。请你看看它。 – Alex
@Alex,显然,你使'return currentExitCode'成为你的应用程序在第一次迭代循环后会留下的退出代码(事件变差,它将完成'main'函数)。从while循环中移出'return ...'行。 –