PyQt4 signals and slots

后端 未结 7 1844
执笔经年
执笔经年 2021-01-31 06:40

I am writing my first Python app with PyQt4. I have a MainWindow and a Dialog class, which is a part of MainWindow class:

self.loginDialog = LoginDialog();
         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 07:14

    You don't use the same signal, when emitting and connecting.

    QtCore.SIGNAL("aa(str)") is not the same as QtCore.SIGNAL("aa"). Signals must have the same signature. By the way, if you are defining your own signals, don't define parametres. Just write SIGNAL('aa'), because defining parametres is a thing from C++ and Python version of Qt doesn't need this.

    So it should look like this:

    QtCore.QObject.connect(self.loginDialog, QtCore.SIGNAL("aa"), self.login)
    

    and if you pass any parametres in emit, your login method must accept those parametres. Check, if this helps :-)

提交回复
热议问题