Unfortunately this is impossible to express using QAbstractItemModel. One can assume the "first" parent is the "real" parent but then again the structure becomes:
Qt Code:
struct Item { Item *parent; QList<Item*> otherParents; QList<Item*> children; };To copy to clipboard, switch view to plain text mode
The only way I see happening to represent a graph as a tree is to "snapshot" a subgraph that actually forms a tree and represent only this snapshot in the model. The data structure itself may contain other members (including pointers to items) however they are not relevant to the tree hierarchy of the model. You may look at it like on a genealogy tree. It is not really a tree but a graph but at a particular moment one is only looking only at its subgraph that is a regular tree.





Reply With Quote
Bookmarks