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. Proxy model filtering for multiple columns

Proxy model filtering for multiple columns

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.8k Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    qxoz
    wrote on last edited by
    #1

    Hi everyone!
    How to create proxy model which can filter by several columns?
    First ugly solution come to my ming is:
    @QSortFilterProxyModel *modelForColumn01 = new QSortFilterProxyModel(this);
    modelForColumn01->setSourceModel(mainModel);
    modelForColumn01->setFilterKeyColumn(1);
    QSortFilterProxyModel *modelForColumn02 = new QSortFilterProxyModel(this);
    modelForColumn02->setSourceModel(modelForColumn01);
    modelForColumn02->setFilterKeyColumn(2);
    @
    but i realy don't like this solution. Is there any solutions for that?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      D0IT
      wrote on last edited by
      #2

      Subclassing "QSortFilterProxyModel":http://qt-project.org/doc/qt-5.0/qtcore/qsortfilterproxymodel.html and reimplementing "filterAcceptsRow":http://qt-project.org/doc/qt-5.0/qtcore/qsortfilterproxymodel.html#filterAcceptsRow should do the job. An example can be found here: "http://www.qtcentre.org/threads/24267-QSortFilterProxyModel-setFilterRegExp-for-more-than-1-column?p=141791#post141791":http://www.qtcentre.org/threads/24267-QSortFilterProxyModel-setFilterRegExp-for-more-than-1-column?p=141791#post141791

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        Thanks D0IT!
        That's what i need :).

        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