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.

Share:
24,044
Dmitro
Author by

Dmitro

Updated on July 15, 2022

Comments

  • Dmitro
    Dmitro almost 2 years

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

  • codeling
    codeling over 8 years
    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...
  • kawing-chiu
    kawing-chiu over 7 years
    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.