I am trying to use the QStandardItem
and QStandardItemModel
to drive a TreeView
in Qt.
In Qt the typical model to control the TreeView
, TableView
& ListView
includes the concept of rows and columns, but also parent/child relationships.
I find the documentation very confusing, because it seems these are interdependent (e.g. to add a child to a QStandardItem
, appendRow()
is used), but nowhere I have found is dedicated to explaining exactly how.
If I had to guess, I would say: "rows are equivalent to children. columns have meaning only within an item itself". Is this correct?
Qt item model is recursive: each item is a table of items. It is incorrect to say that rows are equivalent to children: each index can have a child, no matter what its row column.
Of course, not all views can handle all models. Specifically, no Qt's built-in views can handle children in columns other than 0. But you certainly could implement a view that does!