I am working on a subclass of QAbstractItemModel that connects to a QTreeView . It has a recursive structure of the type Name = Value - any index can have its own subtree. This is good on the left side, because almost every kind of tree there works like this. The problem is that sometimes I want a subtree only on the right side - a list of values. Since I have this right now, it looks like it should work, but Qt never calls rowCount() on the right side and never realizes that there should be a subtree.
The solution that I have now is to create a separate model for it and use setIndexWidget so that each time it leads to a separate tree view. This is fine, but I would really like the subtrees to appear on the right without casting tree-like looks everywhere. My model says that there are subtrees, but Qt just doesn't ask for them.
If this is a bit unclear, this is the basic idea of โโwhat I want to achieve:
- Root | - Name 1 | Value Name 2 | - Compound Value | Sub-value 1 | Sub-value 2 Name 3 | + Compound Value (collapsed) + Name 4 | Value
Be that as it may, the connection values โโwill not have + and - next to them, because Qt never calls hasChildren() or rowCount() in this column, although my model will return it yes, there are children if that were set .
If I finally need to give him an idea of โโa subtree, that's fine. I just wanted to be sure that at first there would be no better way to do this.
source share