Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to filter first row of the model
Forum Updated to NodeBB v4.3 + New Features

How to filter first row of the model

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 467 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
    Madhu M S
    wrote on last edited by
    #1

    I have written model in Qt and i am using QML list view to display the model content. I want to filter zeroth row of the model that means i want to display the content from index 1 to index n. Let me know how can we do it

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Two solution for that :
      You could hide the first row in your delegate, with something like visible: model.index !== 0.
      Or you could really filter it with a proxy model.

      I've written a library to accomplish this : https://github.com/oKcerG/SortFilterProxyModel/

      You could use it this way :

      import SortFilterProxyModel 0.2
      // ...
      SortFilterProxyModel {
          id: proxyModel
          sourceModel: myModel
          filters: IndexFilter { minimumIndex: 1 } // show elements from index 1 and up
      }
      ListView {
          model: proxyModel
          // ...
      }
      
      1 Reply Last reply
      1

      • Login

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