I have a QTableView and a custom model for it. As a model, I use a class inherited from QSortFilterProxyModel with overridden filterAcceptsRow and lessThan . I need to filter the model according to a certain criterion, and then sort it.
There is no problem with filtering. I connected to the rowsAboutToBeRemoved and rowsInserted , after which everything worked fine. However, when I did the sorting, it turned out that the model would not emit the rowsAboutToBeMoved or rowsMoved , which are logical when sorting, so the model is first sorted (visually), and then filters the sorted sequence incorrectly.


For example, I had a model consisting of several elements:
BXZC dah
And I want to sort them alphabetically and leave only upper case letters.
Then, if only filtering is used, the signal will be rowsAboutToBeRemoved , rowsAboutToBeRemoved with start = 4; end = 6 start = 4; end = 6 and after filtering will remain
BDZC (as it should be)
But, if we add sorting there, it will first sort them alphabetically, and then call the same signal with the same start and end .
a BC dh XZ -> a BC d .

What's the catch?

PS There is a lot of code for examples, if you need something specific - write.

    0