[PyQt] Problems with new-style signal/slot syntax

Baz Walter bazwal at ftml.net
Tue Apr 9 21:06:44 BST 2013

When doing new-style connections, I normally use a Python type object as 
the selector (if necessary), and only very occasionally use a string. 
However, I was surprised to discover that this does not always work as 
expected. For example:

     from PyQt4 import QtGui, QtCore
     app = QtGui.QApplication([])
     c = gui.QComboBox()

works okay, but:

     m = QtGui.QMenu()

gives this error:

     KeyError: 'there is no matching overloaded signal'

After a bit of trial and error, it seems that signatures with "plain" or 
"const" arguments work okay, but the ones with "pointer" arguments 
don't. That is, unless the full C++ signature is used, in which case it 
always works:

     m.triggered['QAction *']
     <bound signal triggered of QMenu object at 0x2512b00>

     c.activated['const QString &']
     <bound signal activated of QComboBox object at 0x18308c0>

(Is it intended that these latter two variants work? It doesn't seem to 
be documented anywhere).

Baz Walter

More information about the PyQt mailing list