Full Filter Filter Signal QSortFilterProxyModel

I use custom QSortFilterProxyModelto implement custom filtering for QTableViewby overriding filterAcceptsRow(). How can my application be notified when I change the filtering criteria and then filterAcceptsRow()apply to the whole table?

Basically, I want to get a list of the visible element after applying filtering, I am currently calculating this list using a special function that I implemented in my model, which iterates through the lines and gets a list of visible lines. This is inefficient, since two calls to this function give the same results if nothing happens between the filters.

+4
source share
2 answers

All models must emit layoutAboutToBeChanged()both layoutChanged(), before and after sorting, filtering or changing in any other way that may affect performance.

+5
source

from my observations (in Qt 4.8), the signals are layout*()triggered when the proxy model is sorted, but not when using filtering. documents also explicitly refer to the order of the elements that are implied by these signals, and, of course, filtering does not change the order, but only affects the lines.

rows*(...) (, ..), , . , ( , ), , .

, invalidate() ( invalidateFilter btw, ).

( , ), layout*() , .

/regExp/what , (, setFilterFixedString(...)), , , , - , filterAcceptsRow(...).

, Qt::QueuedConnection, , . ( ), , , .

+3

All Articles