Using QTreeView to show catagories / tags
-
I have a data structure where each item can have a number of tags. What I would like to do is use a QTreeView to list each tag, upon expanding each individual tag, the tree view will show the items identified with this.
The problem comes when implementing the parent method, there is no way to know which is the parent index the model is referring to.
-
@Phill
each QModelIndex can have a internal pointer. This can be any data structure you like. This can be used to identify your specific node.
See the simple tree model example. -
@Phill said in Using QTreeView to show catagories / tags:
I have a data structure
Is this "data structure" already a
QAbstractItemModel
?
If the answer is no then just fill in aQStandardItemModel
manually with your data. no need to reimplement a model.
If the answer is yes then you need aQAbstractProxyModel
subclass. I'm actually working on this proxy but it's not easy. I'll update this post once I implemented it