QSortFilterModel - filter multiple columns



  • Hi All,
    QSortFilterModel -using it i can filter a specific or all columns data but not more than one column.

          Is there a way to filter more than one column? for example i have 5 columns in TreeView.
    

    Now i want to filter column-0, column-2, column-3 with filter text A,B,C respect to columns numbers.
    How this can be accomplished?

    any help would be greatly appreciated

    thanks in advance,



  • You can derive QSFPM and reimplement the filterAcceptsRow method and do the filtering there.



  • Hi Gerolf,
    Thanks for the reply.

    I am already working on it.



  • First search if "somebody else":http://libqxt.bitbucket.org/doc/tip/qxtsortfilterproxymodel.html already invented the wheel before you start to develop your own wheel.



  • Hi Andre,
    Thanks you so much for the link and putting me in the right direction. I will keep that in mind.

    Thanks again.



  • you can use 2 QSortFilterProxyModel:
    the second QSortFilterProxyModel get his sourceModel from the first QSortFilterProxyModel who take his sourceModel from your sourcemodel ....its work



  • you can use 2 QSortFilterProxyModel:
    the second QSortFilterProxyModel get his sourceModel from the first QSortFilterProxyModel who take his sourceModel from your sourcemodel ....its work



  • [quote author="david100100" date="1424022795"]you can use 2 QSortFilterProxyModel:
    the second QSortFilterProxyModel get his sourceModel from the first QSortFilterProxyModel who take his sourceModel from your sourcemodel ....its work[/quote]

    It works, but it is really inefficient. Nice for a quick demo with a small number of items, but so nice for a big dataset in production.

    (Thanks for providing a solution to an over 3 year old problem by the way...)



  • [quote author="david100100" date="1424022795"]you can use 2 QSortFilterProxyModel:
    the second QSortFilterProxyModel get his sourceModel from the first QSortFilterProxyModel who take his sourceModel from your sourcemodel ....its work[/quote]

    It works, but it is really inefficient. Nice for a quick demo with a small number of items, but so nice for a big dataset in production.

    (Thanks for providing a solution to an over 3 year old problem by the way...)



  • Good afternoon,

    I am working on a specific project and I need this feature. The Qt version we are using is 4.8.6. I tried the solution of chaining QSortFilterProxyModel, but I found a strange behaviour at the time to map an item in the filtered final list and the data model.

    Could somebody put a pice of code showing how it is supposed to be done the QSortFilterProxyModel chaining?

    Thank you very much.


Log in to reply
 

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