I have a list of Product objects (in the form of rows), each object has several data fields (for example, product identifier, product family, etc.) - like columns. I managed to subclass the QAbstractTableModel table model and display the data in a QTableView.
What I want is a "grouped" view of the model in a tree structure. For example, I want to group products by their family id, so the tree should contain groups at the first level (family identifier) and their children are the product that has this family identifier.
Any ideas?
PS: The need for several groupings (group by family ID and grouping by another column, etc.) shows me that the model should be a tree. Root nodes indicate groups, and then the children are members of the group. Multiple grouping can be achieved by tiered trees.
Then my converted question is: How can I implement a special QTableView class that only displays the leaves of a tree (at a given level)? (Because actually the leaves are real objects that we would like to see in the grid)
I can use setRootIndex in the table view, but it does not solve anything, other sheets are not displayed.
I dug a little and found that in QTableView :: paintEvent, when displaying each row and column, the actual element is selected like this:
const QModelIndex index = d- > model- > index (row, col, d- > root);
d- > root() - node, setRootIndex(). , . paintEvent?
Veress Krisztian