我有一些这样的代码:
class MyApp(Ui_MainWindow):
def __init__(self):
pass
def setupUi(self, *args):
super(MyApp, self).setupUi(*args)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.doCheck)
def doCheck(self):
self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Checking...", None, QtGui.QApplication.UnicodeUTF8))
# Code to do real checking here... (it's a network app)
# When check done, display result in a "QTextBrowser"
# ....
# Change text of Button to "Done!"
self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Done!", None, QtGui.QApplication.UnicodeUTF8))
但结果并不如我所料。我的应用程序进行网络检查并显示结果正常,但检查开始时按钮没有将文本更改为“正在检查...”;它只是将文本更改为“完成!” 当一切都完成了!