PySide Qt Creator消息对话框退出

所以我用Qt Creator创建了一个包含QPushButton的ui文件。 只是为了测试的目的,我想弹出一个QMessageDialog,声明你好! 在主窗口类中打开ui之后,我将ui的按钮连接到def hello(self):

myWidget.helloButton.clicked.connect(self.hello)

然后再

def hello(self):
    QtGui.QMessageBox.question(self,'Message',"hello!",QtGui.QMessageBox.Ok)

消息弹出“你好!” 在消息对话框中单击“确定”后,整个python程序退出,有效地崩溃了主窗口GUI

当我没有使用UI文件时,这并没有发生在我身上。 有谁知道为什么会发生这种情况?

提前致谢。

编辑:只要我点击“确定”就会发生这种情况

Traceback (most recent call last):
File "C:UsersGeorgeDesktoploadui..py", line 25, in <module>
main()
File "C:UsersGeorgeDesktoploadui..py", line 23, in main
sys.exit(app.exec_())
SystemExit: 0

QDialog的父对象从self更改为QtGui.QApplication.activeWindow()为我工作。

链接地址: http://www.djcxy.com/p/54787.html

上一篇: PySide Qt Creator message dialog exit

下一篇: What exactly are iterator, iterable, and iteration?