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. how get filtered data from QSortFilterProxyModel ?
Forum Update on Monday, May 27th 2025

how get filtered data from QSortFilterProxyModel ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 3.0k 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.
  • P Offline
    P Offline
    paghsa
    wrote on 31 Jul 2021, 13:39 last edited by
    #1

    hi guys
    i just have a QAbstractItemModel and i filter data according to QSortFilterProxyModel
    what i want is so simple , i just want to separate and loop over filtered data but i have no idea for that .
    any help will be appreciated
    thanks

    J 1 Reply Last reply 31 Jul 2021, 14:04
    0
    • P paghsa
      31 Jul 2021, 13:39

      hi guys
      i just have a QAbstractItemModel and i filter data according to QSortFilterProxyModel
      what i want is so simple , i just want to separate and loop over filtered data but i have no idea for that .
      any help will be appreciated
      thanks

      J Offline
      J Offline
      JonB
      wrote on 31 Jul 2021, 14:04 last edited by JonB
      #2

      @paghsa said in how get filtered data from QSortFilterProxyModel ?:

      and i filter data according to QSortFilterProxyModel

      If you have done this you already have what you ask for? Just iterate/access via the QSortFilterProxyModel, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare what QSortFilterProxyModel::rowCount() returns versus the source model's QAbstractItemModel::rowCount().

      P 2 Replies Last reply 31 Jul 2021, 14:31
      0
      • J JonB
        31 Jul 2021, 14:04

        @paghsa said in how get filtered data from QSortFilterProxyModel ?:

        and i filter data according to QSortFilterProxyModel

        If you have done this you already have what you ask for? Just iterate/access via the QSortFilterProxyModel, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare what QSortFilterProxyModel::rowCount() returns versus the source model's QAbstractItemModel::rowCount().

        P Offline
        P Offline
        paghsa
        wrote on 31 Jul 2021, 14:31 last edited by paghsa 8 Jan 2021, 04:49
        #3

        @JonB
        oh god it was dead simple
        anyways thanks a lot ;)
        for other people who may face to this problem you should use proxy->index() and play with it

        QModelIndex index = proxyModel->index(row , column , parentIndex);
        int rowCount = proxy->rowCount(proxyModel); // it gives you the count of rows 
        qInfo() << proxy->data(index , sourceModel::enum); // it prints the corresponding data
        

        in my case i have a treeModel and have to search all filtered rows for particular value.

        1 Reply Last reply
        0
        • J JonB
          31 Jul 2021, 14:04

          @paghsa said in how get filtered data from QSortFilterProxyModel ?:

          and i filter data according to QSortFilterProxyModel

          If you have done this you already have what you ask for? Just iterate/access via the QSortFilterProxyModel, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare what QSortFilterProxyModel::rowCount() returns versus the source model's QAbstractItemModel::rowCount().

          P Offline
          P Offline
          paghsa
          wrote on 31 Jul 2021, 15:52 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          1/4

          31 Jul 2021, 13:39

          • Login

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