Unsolved QAbstractItemModel item identification from ModelIndex
I need a QTreeView with a model referring to existing data(using C++).
The data is a tree, using raw pointers in its nodes. I can reach any node by a custom unique ID.
If I understand the paradigm correctly, my model have to implement functions like 'parent' in which I need to tell the parent item's ModelIndex from the ModelIndex of the child. I can do this by storing the data tree pointers in ModelIndex. This can be unsafe in my case. Is there any other option to handle this correctly?
HI and welcome to devnet,
Why is it unsafe in your case ?
Did you already saw the Simple Tree Model example in Qt's documentation ?
Hi! Thanks for the answer
I think it is unsafe beacause my data tree can change by other mechanisms.
I don't think that keeping pointers to dynamically changing data is a good idea in general.
I've tried it( because I had no better idea) and now I have some new problem. I will post them to another topic.
Then you have to propagate the information when your underlying data changes.