[PyQt] chain signals, disconnecting an "emit" slot

Pierre-Louis Bonicoli pierre-louis.bonicoli at gmx.fr
Fri Oct 7 17:42:39 BST 2011


Hi,

I encounter a problem using "emit" method of a signal as a slot of
another signal. Problem occurs using "disconnect".

Here is sample code, 'ok' and 'cancel' inherit from QAbstractButton:

ok.pressed.connect(cancel.pressed.emit)
ok.pressed.disconnect(cancel.pressed.emit)

The second statement raise an exception:
"TypeError: 'builtin_function_or_method' object is not connected"

Calling "disconnect" without parameter works fine.

If I use an intermediate function, TypeError is not raised:

def reemit():
    cancel.pressed.emit()

ok.pressed.connect(reemit)
ok.pressed.disconnect(reemit)

Behaviour is the same with old style signals.

Is there a way to not use an intermediate function ?

sip: 4.12.4
PyQt: 4.8.3
Qt: 4.7.3

Test cases in attachment.

Thanks,

Pierre-Louis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 2405 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20111007/24b0b76e/attachment.py>


More information about the PyQt mailing list