8

I need working examples (c++) of show own data model in QtreeView.

Dmitro
  • 1,870
  • 3
  • 16
  • 25
  • 5
    That'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 Answers1

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
  • 6
    what 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
  • 6
    Qt'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