I'm fairly new to Qt and therefor try to find out how things are working. Especially for QTreeView this seems to be quite difficult: the documentation and the example that come from Qt are (at least for me) more or less cryptic. I'd guess one will understand this documentation only when one already knows how it works.
So: could someone give an example or an link to an example which is beginner-suitable and demonstrates the usage of QTreeView? Means which demonstrates how to add a node and some child nodes to it?
Thanks!
You can start with the combination of QStandardItemModel
and QTreeView
.
Set the proper row and column count of your model by QStandadItemModel::setRowCount()
and QStandardItemModel::columnCount()
.
Then you can insert a QStandardItem instance into the particular cell of the model with the QStandardItemModel::setItem()
.
QStandardItem
has a similar interface to QStandardItemModel
for creating child rows and columns and inserting a child items: QStandardItem::setRowCount()
, QStandardItem::setColumnCount()
and QStandartItem::setChild()
.
I can prepare an example if you need one.