I'm working on a subclass of QAbstractItemModel
that plugs into a QTreeView
. It has a recursive Name = Value
type structure - any index could have its own subtree. This is fine on the left side, because almost every tree view out there works that way. The problem is that sometimes I want a subtree only on the right side - a list of values. As I have it right now, it seems like it should work, but Qt is never calling rowCount()
for the right side, and never realizing that there should be a subtree there.
The solution that I have right now is basically to create a separate model for that, and use setIndexWidget
to give it a separate tree view every time this happens. That's fine, but I'd really like to get the subtrees showing up on the right without having to throw tree views all over the place. My model responds that there are subtrees over there, but Qt just never asks for them.
If this is a little unclear, this is the basic idea of what I want to accomplish:
- Root |
- Name 1 | Value
Name 2 | - Compound Value
| Sub-value 1
| Sub-value 2
Name 3 | + Compound Value (collapsed)
+ Name 4 | Value
As it is, the compound values will not get the +
's and -
's next to them because Qt never calls hasChildren()
or rowCount()
in that column, even though my model would return that yes, there are children, if it was asked.
If I end up having to give it a sub-tree view, that's fine. I'd just like to be sure that there's not a better way to do it first.