I am trying to create a QTreeView that displays some sorted information. For this, I use QSortFilterProxyModel between the view and my model.
The problem is that I want to limit the number of lines for the first n lines (after sorting). The filter function from the model gets the source code, so I cannot use it.
I tried to link two QSortFilterProxyModel: the first for sorting and the second for filtering. But it seems that the second proxymodel (filtering) is not getting sorted rows ....
Is there any other way to do this? Does anyone use this technique (a chain of two proxy models) and it works?
Thank you
EDIT: I tried with rowCount and it does not work. I also tried to combine 2 proxy models, but the problem is that the view calls the sort function for the model it receives. Therefore, if the first proxy sorts and the second filter, the sort will be called in the filter model, and the data will not be sorted.
EDIT2: I looked at the qt source code and filtering is done before sorting, so in filterAcceptsRow () I don't know the sort order.
Ionut anghelcovici
source share