I need working examples (c++) of show own data model in QtreeView.
Asked
Active
Viewed 2.5k times
8
-
5That's too vague for Stack Overflow : you should try Google to get you started and come ask questions when you encounter more specific problems. – icecrime Dec 04 '10 at 16:33
1 Answers
7
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.

user2567875
- 482
- 4
- 21

asdfjklqwer
- 3,536
- 21
- 19
-
6what 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... – codeling Oct 02 '15 at 10:07
-
6Qt'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 the `index()/parent()` methods), which in effect provides no separation of view/model at all. – kawing-chiu Sep 30 '16 at 03:38