[PyKDE] Model indexes and internal pointers
Jeremy Sanders
jeremy at jeremysanders.net
Wed Jul 19 09:52:13 BST 2006
On Wed, 19 Jul 2006, David Boddie wrote:
> Probably, but there's not much you can do if you attach Python objects
> to temporary C++ objects and pass them back to Qt. If you just prevent
> them from being collected, there's the chance that they'll become
> unrecoverable. Maybe the handling of QPersistentModelIndex needs to be
> looked at more closely.
I ran into this issue when trying to write a bridging tree layer to
convert from the tree in my python code to the treemodel for the treeview.
These bridging objects would get collected. It's very hard to do this with
the current code.
In the end I directly connected the model indexes to my internal python
structure. I used a weakref.WeakValueDictionary() to map the model index
IDs to my internal objects.
Jeremy
--
Jeremy Sanders <jeremy at jeremysanders.net>
http://www.jeremysanders.net/ Cambridge, UK
Public Key Server PGP Key ID: E1AAE053
More information about the PyQt
mailing list