-
QTreeView model
I'm trying to get back into Qt after a long break. I'm trying to write a model for my QTreeView. It's for managing my music collection and whatnot. I have a tree item for the artist, album and track. The problem is trying to get those three items done correctly in my QAbstractItemModel. I only see entries for one tree item and nothing like mine. Any ideas, or examples for my situation?
-
Re: QTreeView model
-
Re: QTreeView model
Not really helpful, as that only explains how to use one tree item, while I need one for multiple different tree items.
-
Re: QTreeView model
You need to create a custom model that wraps three different tree representations of your collection database. You switch among these three trees based on a top level model index:
model index 0,0 chooses the artist tree
model index 1,0 chooses the album tree
model index 2,0 chooses the track tree
Once you have chosen the correct tree based on the top-level parent of the model index you have been given as the argument (e.g. to the QAbstractItemModel::data() method), then retrieving the correct sub-tree entry simply means going down that sub-tree until you get to the right child.