参数与任何重载调用都不匹配

arguments did not match any overloaded call

我正在使用 python 和 qt 设计器,当我在我的控制器上工作时出现这个错误:

File "/home/sabri/Bureau/PycharmProjects/PFE/Controller/Cat.py", line 14, in init self.ui.AddBtn.connect(self.add) TypeError: arguments did not match any overloaded call: QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'instancemethod' QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'instancemethod' QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'instancemethod'

这是我第一次收到这个错误,这是什么问题! 这是我的代码:

from PyQt4 import QtCore, QtGui
from PFE.Classes.categorie import Category
from PFE.Interfaces.Categorie import Ui_Categorie_2

class Window(QtGui.QDialog):

    def __init__(self):
        QtGui.QApplication.__init__(self)
        self.ui = Ui_Categorie_2()
        self.ui.setupUi(self)
        self.ui.AddBtn.connect(self.add)


    def add(self):
        a = str(self.ui.textEdit.toPlainText())
        b = str(self.ui.textEdit_2.toPlainText())
        cat=Category(a, b)
        cat.save_to_db()
        print ("ajout avec success ")



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

信号与其槽的连接方式如下:

{sender}.{signal}.connect({slot})

考虑到 AddBtn 是一个按钮,并且您想使用点击信号,您的代码应如下所示:

self.ui.AddBtn.clicked.connect(self.add)