I’m a bit confused about QModelIndex concerning the fact that you need to have a parent index to get an index value for an item in a tree model. That makes perfect sense if the item your obtaining an index value for, is the child of another item.

However if you need the index value for a top level item, it is unclear to me about how to obtain or create that value since the parent of top level items is the root and it doesn’t appear that you can obtain a QModelIndex for the root.

I’ve attempted to make a QModelIndex at row 0 column 0 but since there is no parent for that position, it doesn’t quite work. I have also used a null QModelIndex using QModelIndex() as the parent, and that too, does not appear to work.

At this point, I’m thinking I may be going about this all wrong, so if anyone can clear up my confusion concerning this issue, I would certainly appreciate it.

Thanks in advance
Corny