Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSortFilterModel - filter multiple columns

QSortFilterModel - filter multiple columns

Scheduled Pinned Locked Moved General and Desktop
11 Posts 6 Posters 5.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    ManasQt
    wrote on 11 Oct 2011, 14:13 last edited by
    #1

    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,

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 11 Oct 2011, 14:46 last edited by
      #2

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

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        ManasQt
        wrote on 11 Oct 2011, 15:17 last edited by
        #3

        Hi Gerolf,
        Thanks for the reply.

        I am already working on it.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 11 Oct 2011, 15:19 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            ManasQt
            wrote on 11 Oct 2011, 16:27 last edited by
            #5

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

            Thanks again.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              david100100
              wrote on 15 Feb 2015, 17:53 last edited by
              #6

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

              1 Reply Last reply
              0
              • D Offline
                D Offline
                david100100
                wrote on 15 Feb 2015, 17:53 last edited by
                #7

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

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 15 Feb 2015, 19:03 last edited by
                  #8

                  [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...)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on 15 Feb 2015, 19:03 last edited by
                    #9

                    [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...)

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Miguel Mejias
                      wrote on 24 Apr 2015, 15:50 last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mindon
                        wrote on 24 Nov 2023, 02:04 last edited by
                        #11

                        Here's an implement https://gist.github.com/mindon/a2a0432c9ede07b627f62af94ac95a96

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved