On Mon, Apr 13, 2009 at 3:11 PM, Andreas Pakulat <ap...@gmx.de> wrote:
> On 13.04.09 10:27:56, Darren Dale wrote: > > On Mon, Apr 13, 2009 at 9:58 AM, Andreas Pakulat <ap...@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. > Ok, I think I get it, thank you. When I get time, I'll improve the example I posted in the other thread and share it with the list. Darren
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt