[PyQt] Signal on Selection in QTreeView

Phil Thompson phil at riverbankcomputing.com
Tue Mar 18 13:44:01 GMT 2008


On Tuesday 18 March 2008, Marius Kintel wrote:
> On Mar 18, 2008, at 2:57 AM, Kevin Foss wrote:
> > 	To show you my difficulties, I've tried to test this whole
> > selection model
> > capability using an example from David Boddie at Trolltech.  It can
> > be found
> > here:
> >
> > http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/8447872
> >.html
> >
> >      	Guess what, even his example doesn't work.  When I run his
> > example,
> > nothing is printed when an item is selected.
>
> I think I can help.
> I spend a lot of time figuring out how this works a month or so back.
> My results can be summed up like this:
>
>     ** Never connect a Qt signal to a global python function **
>
>     If the python wrapper object dies (common for temporary wrapper
> objects), the connection goes down with it.

What makes you say that? The connection has nothing to do with the wrapper 
object of the emitter.

> Instead, connect to a 
> python instance method. This is handled in a special way in SIP making
> the connection survive the temporary python wrapper object.
>
> Taking my own advice, the example program you mention can be fixed by
> making the slot an instance method instead:

This should make no difference.

Phil


More information about the PyQt mailing list