PDA

View Full Version : Problems creating parent qmodelindex for setData



smick
10th August 2012, 18:16
Hello experts

I have a tree model based on the qt editable tree model example

The model has a structure as follows

-root

-a


-b



-c




-item0




-item1




.......

Hope the sketch above makes sense, showing 4 levels of hierarchy

I want to setData for 'item1' in a class that uses the model and is not a subclass of the model, so I cant use createIndex.
I have a pointer to the item1 tree item but I need a parent QModelIndex for item 'c'.

It looks like I need to recursively traverse the tree structure in order to create the index. Is there a better way to do this.

Any ideas, am I on the right track?

Regards