QTreeView and QSortFilterProxyModel: On-demand model population
I am using a QTreeView with a model that populates items with children on demand, i.e., only when the item is expanded. To achieve this, the model returns true for hasChildren() before the first expansion, while rowCount() returns 0.
This worked well, until I tried to add a proxy between the model and the view, so that items could be filtered. The proxy returns false for hasChildren(), regardless of the result provided by the underlying model. This means that the expansion icons are not drawn, and the use can not open new items.
Is there another way to force the tree to draw the expansion icons?
Thanks,
--Elad
Re: QTreeView and QSortFilterProxyModel: On-demand model population
subclass the proxy and return true again in hasChildren() ?
Re: QTreeView and QSortFilterProxyModel: On-demand model population
I wish it were that simple...
QSortFilterProxyModel declares this method as non-virtual. That was the first thing I checked.
--Elad
Re: QTreeView and QSortFilterProxyModel: On-demand model population
yeeeeees.... BUT:
it is virtual in the base class. A virtual method stays virtual, that's the point!
(Whether the sub class re-declares the virtual is not important.)
Re: QTreeView and QSortFilterProxyModel: On-demand model population
OK, thanks.
I thought it had to be declared virtual in the immediate base class as well (I can certainly see a benefit to masking virtual functions, in order to ensure certain behaviour, but that's off-topic).
--Elad