PyQt4 error: unexpected type 'method'

PyQt4 error: unexpected type 'method'

我正在尝试 运行 一个简单的 PyQT4 应用程序。我已经安装了 Python3.4 和 PyQt4。我已经测试了一个简单的 "Hello World" 应用程序并且一切正常。但是,在尝试编写一个简单的税收计算器应用程序时,我遇到了 "unexpected type 'method'" 错误。不知道我做错了什么。这是我的 python 代码:

import sys
from PyQt4 import QtCore, QtGui, uic

qtCreatorFile = 'tax.ui' # Enter file here.

Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)

class MyApp(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.calcTax.connect(self.CalculateTax)

    def CalculateTax(self):
        price = int(self.priceBox.toPlainText())
        tax = (self.taxRate.value())
        total_price = price  + ((tax / 100) * price)
        total_price_string = 'The total price with tax is: ' + str(total_price)
        self.resultBox.setText(total_price_string)

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec_())

这是执行时返回的完整错误消息:

Traceback (most recent call last):
  File "tax.py", line 24, in <module>
    window = tax()
  File "tax.py", line 13, in __init__
    self.calcTax.connect(self.CalculateTax)
TypeError: arguments did not match any overloaded call:
  QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'method'
  QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'method'
  QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'method'

非常感谢任何帮助

new connection style 的语法如下:

self.calcTax.some_signal.connect(self.CalculateTax)

例如,如果 self.calcTax 是一个按钮,你想在按下该按钮时执行该功能,你应该输入以下内容:

self.calcTax.clicked.connect(self.CalculateTax)