[PyQt] chain signals, disconnecting an "emit" slot
Phil Thompson
phil at riverbankcomputing.com
Fri Oct 7 17:55:33 BST 2011
On Fri, 07 Oct 2011 18:42:39 +0200, Pierre-Louis Bonicoli
<pierre-louis.bonicoli at gmx.fr> wrote:
> 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
You can connect signals to signals...
ok.pressed.connect(cancel.pressed)
Phil
More information about the PyQt
mailing list