[Qt-interest] simple tree model example

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Thu May 20 13:02:18 CEST 2010


Hi All,

While reading up the model-view programming docs, I came across the
simple tree model example which illustrates how to use the abstract
model for implementing a hierarchical tree like data (since there's no
existing class (like QListview/QTableView) which can handle such
category of data).

http://doc.qt.nokia.com/4.6/itemviews-simpletreemodel.html

While going through the other available model classes, I came across
QStandardItemModel/QStandardItem which seems to be capable of holding
tree like data structures.

Is QStandardItemModel, the right model for holding tree-like data? If
so, why wasn't this model used in the simple tree model?

I have used QStandardItemModel populated with my tree data and applied
a QTreeView to it and everything has worked fine till now.

Just wondering why, in the simple tree model example, they used the
QAbstractItermModel as base and not QStandardItemModel. The model-view
programming guide states:

"QStandardItemModel manages more complex tree structures of items,
each of which can contain arbitrary data."

Hence my confusion.

Thanks,
-mandeep

PS: BTW one OT question - who are "Trolls"? ppl who work on QT itself?
or anybody who uses QT, like app devs? Just curious. :)



More information about the Qt-interest-old mailing list