QAbstractItemModel and QTreeView
24,044
There's a pretty good QTreeView/QAbstractItemModel example here. It's fairly straightforward once you get used to QT's ultra-generic model... just don't expect it to be as simple or obvious as Java's TreeModel.
Author by
Dmitro
Updated on July 15, 2022Comments
-
Dmitro almost 2 years
I need working examples (c++) of show own data model in QtreeView.
-
codeling over 8 yearswhat I find quite bad about the linked article is that it mainly describes how their example works, and only in between a bit about how the QTreeView uses that model. in addition, it isn't explained under which circumstances one should even write an own model, when there is a quite potent one available already (QStandardItemModel). Not related to that article but to this answer: answers should contain the main gist of linked article (in case of a website going offline), that's missing here...
-
kawing-chiu over 7 yearsQt's treeview works like a sh*t since it forces you to create a real tree for the underlying data when you use
QAbstractitemModel
(if you don't, you will soon lost in theindex()/parent()
methods), which in effect provides no separation of view/model at all.