[PyQt] From object IDs to objects to model indexes...

Aaron Digulla digulla at hepe.com
Tue Feb 12 19:35:02 GMT 2008


Dirk Wagener schrieb:
> Hi
> 
> I am using QModelIndex constructed with an id. I am using the built-in
> method
> id(my_object) to get an ID to construct a ModelIndex with.
> If we have an index, internalId() returns the id used to create the index.
> Is there a API way to get the ModelIndex from a view if we have the id used
> to create the index? I do not see a method like this in the QModelIndex API.
> 
> Also, id(my_object) = ID. Is there a way to get my_object if I only have
> the ID?

In python, I would just add a dictionary to the model object and store
the mapping in there whenever you add items to the model.

Regards,

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://darkviews.blogspot.com/          http://www.pdark.de/


More information about the PyQt mailing list