[PyKDE] Binding parameters to slots
Phil Thompson
phil at riverbankcomputing.co.uk
Thu Dec 16 15:38:37 GMT 2004
> Hi -
>
> I'm trying to connect a signal in my class to a signal, but bind one of
> its parameters to the signalling object:
>
> For instance, I want to do something like
>
> self.connect( button, qt.SIGNAL('clicked()'),
> lambda button=button: sys.stdout.write(button) )
>
> or
>
> self.connect( button, qt.SIGNAL('clicked()'),
> lambda button=button, self=self: self.slotTest(button) )
>
> None of the options I've tried seem to work. Is this possible??
The problem is that connect() does not take a reference to the slot
object, and the lambda function is garbage collected as soon as connect()
returns.
Phil
More information about the PyQt
mailing list