[PyQt] segfault when using a proxy and SIGNAL( "clicked(QModelIndex)" )

Andreas Pakulat apaku at gmx.de
Mon Apr 13 20:11:36 BST 2009


On 13.04.09 10:27:56, Darren Dale wrote:
> On Mon, Apr 13, 2009 at 9:58 AM, Andreas Pakulat <apaku at gmx.de> wrote:
> > On 13.04.09 14:11:46, Arnold Krille wrote:
> > > It is a pointer for internal purposes, that is internal for the model
> > > so it can map indexes to the internal data structures. (And yes, that
> > > is needed for anything except simple list or table models.:)
> >
> > <nitpick>Thats not true actually, you can create the most complex model
> > imaginable without using the internalPointer, simply by using the
> > internalId and the related createIndex overload. That also automatically
> > solves any problems created by python's refcounting+garbage collection
> > (if you forget to store a reference to an object for the model in your
> > model)
> 
> Could you please sugggest an example of this approach, if you know of one?

Thats easy, provide some way of hashing the objects in your tree, then
use the hashnumber for the internal id. Often using id(yourobject) works
quite well as internal id. Then all you need is a dict using the id as
key and the real object as value, so you can easily look your object up.
Or maybe your internal data layout already orders the objects in some
way, then the searching through that tree might be efficiently possible
and you don't need the dict at all. I don't have a pyqt source tree
here, but I think the tree model example uses internalId for storing and
identifier for each object.

Andreas

-- 
Lady Luck brings added income today.  Lady friend takes it away tonight.


More information about the PyQt mailing list