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 display the search result on QListView?

How to display the search result on QListView?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 885 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.
  • T Offline
    T Offline
    tokafr
    wrote on last edited by
    #1

    Hello all.

    I have such task, I want to search an item in model(QAbstractListModel) and display only the result of search on QListView,
    How can I do it?

    thank you.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      AFAIK you can use "QSortFilterProxyModel":http://doc.qt.io/qt-5/qsortfilterproxymodel.html for this. Create a model based on QAbstractListModel and the use "setSourceModel":http://doc.qt.io/qt-5/qsortfilterproxymodel.html#setSourceModel to set this model as source to QSortFilterProxyModel. To filter out the items you can re-implement "filterAcceptsRow":http://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow and return true or false per the search criteria.

      157

      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