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 to mix QSortFilterProxyModel and QAbstractTableModel with fetch more function
Forum Updated to NodeBB v4.3 + New Features

How to mix QSortFilterProxyModel and QAbstractTableModel with fetch more function

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 625 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.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by
    #1

    Hi
    I'm using QTableView and a model inheriting QAbstractTableModel with fetch-more function like fetch more example.
    Now I want to add a filter. But I dont' know how to get the count of the data after filtering, to be used in fetch-more function. And how to update filtered data used in QAbstractTableModel::data()

    Regards
    Mihan

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      There is nothing special to do. fetchMore() notifies the proxy model of the new rows inserted via beginInsertRows/endInsertRows so there is nothing special to do. QSortfilterProxyModel will work automatically

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      MihanM 1 Reply Last reply
      2
      • VRoninV VRonin

        There is nothing special to do. fetchMore() notifies the proxy model of the new rows inserted via beginInsertRows/endInsertRows so there is nothing special to do. QSortfilterProxyModel will work automatically

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by Mihan
        #3

        @VRonin
        But I find that the list will not add new item but will update data if I just update the data vector and do not update the visible count.
        e.g.

        void updateData()
        {
            beginResetModel();
        
            GetDataVector(m_Vector);
        
            //without reset the visible count
            //m_VisibleCount = 0;
        
            endResetModel();
        }
        

        Also I find it will update well if I click the buttom item.

        how to improve it? Because I also want to real-time updata it.

        VRoninV 1 Reply Last reply
        0
        • MihanM Mihan

          @VRonin
          But I find that the list will not add new item but will update data if I just update the data vector and do not update the visible count.
          e.g.

          void updateData()
          {
              beginResetModel();
          
              GetDataVector(m_Vector);
          
              //without reset the visible count
              //m_VisibleCount = 0;
          
              endResetModel();
          }
          

          Also I find it will update well if I click the buttom item.

          how to improve it? Because I also want to real-time updata it.

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @Mihan said in How to mix QSortFilterProxyModel and QAbstractTableModel with fetch more function:

          But I find that the list will not add new item but will update data if I just update the data vector and do not update the visible count.

          I'm sorry but I'm a bit slow. could you explain what you mean here?

          it will update well if I click the buttom item.

          what button item?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          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