QSortFilterProxyModel filter by multiple coloumns



  • Hello, i'm hoping for some help here.

    Im having problems with filtering data. I have two QLineEdits, one is connected to filter the first column in table model, the other is connected to filter the second coloumn. For example if I filter by first coloumn, table refreshes and shows only rows with that paritucular regExp, but when I filter with coloumn one and then with coloumn two, filterRegExp ignores the coloumn one and filteres the model only by second column.
    I know that filterRegExp searches the whole source model and that's the problem. After filtering with first column I want to filter the filtered table model, not the whole model. Is there a way to achieve this?

    Thanks



  • You could stack two QSortFilterProxyModels on top of the each other, one filtering on the first column/value, and the other on the second column/value.

    Alternatively, you could subclass QSortFilterProxyModel to override filterAcceptsRow() and compare two columns against two filter values (the first is the existing column and value, and a second you add)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.