[Interest] Why doesn't my model filter update?

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Feb 18 21:35:13 CET 2020


I have a QAbstractItemModel. I also have a QSortFilterProxyModel acting
as a filter for the model, which in turn is used to feed a QTreeView.
The filter accepts or rejects rows based on a custom data role of the
source model.

However, when the source model's data changes, the tree view does not
update, and the filter's filterAcceptsRow is never called. What could I
be doing wrong?

The filter *does* have filterRole set correctly, and *does* have
dynamicSortFilter set. (filterKeyColumn isn't set, but I'm using 0, and
anyway setting it to -1 had no effect.) I've verified that the source
model is emitting dataChanged() and is not blocking signals.

The filter setup is at
https://github.com/Kitware/seal-tk/blob/master/sealtk/gui/AbstractItemRepresentation.cpp#L47-L48.
The model dataChanged is emitted at
https://github.com/Kitware/seal-tk/blob/master/sealtk/core/AbstractProxyModel.cpp#L135.

-- 
Matthew


More information about the Interest mailing list