[PyQt] QAbstractItemModel causes segfault
sebastianelsner at freenet.de
Mon Apr 12 08:41:08 BST 2010
No ideas on this one?
On Wed, 07 Apr 2010 18:14:28 +0200, Sebastian Elsner
<sebastianelsner at freenet.de> wrote:
> One additional question:
> You wrote, that internalPointer() is not meant to be used outside of the
> model. But how would I get the associated object from a QModelIndex?
> I am using selectedIndex() on the view to get the indexes, but how to
> proceed from there on?
> is On Tue, 06 Apr 2010 17:40:09 +0200, Phil Thompson
> <phil at riverbankcomputing.com> wrote:
>> On Tue, 06 Apr 2010 16:23:30 +0200, "Sebastian Elsner"
>> <sebastianelsner at freenet.de> wrote:
>>> I finally was able to compile an example case, which is not too
>>> please find it attached. Run the python script, expand one LevelOne
>>> and select a LevelTwo item and in the menu choose add/edit levelthree.
>>> you do this you should see an error or the interpreter will crash (try
>>> adding more items und expand them!). As said this error can be
>>> by adding strong references for all items in the tree (which is
>>> the createIndex obviously does not). Uncomment line 210 and 211 to see
>>> that adding all items to a list helps.
>>> The root item is owned by the model, so this should work, right?!
>> The root item is owned by the model, but does the root item own all of
>> children, grandchildren etc.? I can see that it owns its children
>> you explicitly call its appendChild() method, but I'm not clear where
>> children's equivalent methods are called. Have you tried printing out
>> tree of items starting with the root item at various point to make sure
>> tree contains what you think it should?
>> QAbstractItemModel won't maintain your model for you. As the
>> says, it "provides the abstract interface for item model classes" - the
>> word being "interface". It is not the container of the model data -
>> the responsibility of a sub-class.
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the PyQt