PyQt4 signals and slots

pyqt, pyqt4, python, qt, qt4

Solution

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 :-)

Problem

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(); ``` I use slots and signals. Here's a connection made in MainWindow: ``` QtCore.QObject.connect(self.loginDialog, QtCore.SIGNAL("aa(str)"), self.login) ``` And I try to emit signal inside the Dialog class (I'm sure it is emitted): ``` self.emit(QtCore.SIGNAL("aa"), "jacek") ``` Unfortunately, slot is not invoked. I tried with no arguments as well, different styles of emitting signal. No errors, no warnings in the code. What might be the problem?

Original source