<br><br><div class="gmail_quote">On Mon, Apr 13, 2009 at 3:11 PM, Andreas Pakulat <span dir="ltr"><<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 13.04.09 10:27:56, Darren Dale wrote:<br>
> On Mon, Apr 13, 2009 at 9:58 AM, Andreas Pakulat <<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>> wrote:<br>
> > On 13.04.09 14:11:46, Arnold Krille wrote:<br>
> > > It is a pointer for internal purposes, that is internal for the model<br>
> > > so it can map indexes to the internal data structures. (And yes, that<br>
> > > is needed for anything except simple list or table models.:)<br>
> ><br>
> > <nitpick>Thats not true actually, you can create the most complex model<br>
> > imaginable without using the internalPointer, simply by using the<br>
> > internalId and the related createIndex overload. That also automatically<br>
> > solves any problems created by python's refcounting+garbage collection<br>
> > (if you forget to store a reference to an object for the model in your<br>
> > model)<br>
><br>
> Could you please sugggest an example of this approach, if you know of one?<br>
<br>
</div>Thats easy, provide some way of hashing the objects in your tree, then<br>
use the hashnumber for the internal id. Often using id(yourobject) works<br>
quite well as internal id. Then all you need is a dict using the id as<br>
key and the real object as value, so you can easily look your object up.<br>
Or maybe your internal data layout already orders the objects in some<br>
way, then the searching through that tree might be efficiently possible<br>
and you don't need the dict at all. I don't have a pyqt source tree<br>
here, but I think the tree model example uses internalId for storing and<br>
identifier for each object.<br>
</blockquote><div><br>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.<br><br>Darren <br></div></div>