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. Way to filter/search ListView contents
Forum Updated to NodeBB v4.3 + New Features

Way to filter/search ListView contents

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 6.4k 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.
  • M Offline
    M Offline
    morte
    wrote on last edited by
    #1

    I looking for an elegant way to filter ListView contents by text in TextInput (as in Android contacts).

    My current suggestions:

    1. Changing visible property of delegate.
      That should have good perfomance, but ListView reserves space for empty delegates, and user see empty fields, need to hide non-visible delegates somehow.
    2. Using two ListModel instances. First instance stores full set of data, second stores filtered subset, view connected to second. That method have high memory and processor time costs: each time when filter expression changes we need to clear second model then fill it again with new subset of data.
    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      This is a job for QSortFilterProxyModel. Attach your ListView to the proxy model, not the original model.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • M Offline
        M Offline
        morte
        wrote on last edited by
        #3

        Yeah, QSortFilterProxyModel exactly for that task, but currently i sticked to QML ListModel, don't know maybe its possible to connect QSortFilterProxyModel to ListModel.

        Maybe someone have suggestions on how implement that with QML/JS?

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Sorry, my brain wasn't working properly -- I completely missed the fact that you're working in QML.

          Anyway, does this help?: http://kunalmaemo.blogspot.com.au/2013/04/creating-qml-listview-with-search.html

          (I Googled "QML filter model")

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          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