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. Filter in QListView
Qt 6.11 is out! See what's new in the release blog

Filter in QListView

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

    I do the query and show that in QListView.

        QSqlQueryModel * model = new QSqlQueryModel(0);
        model->setQuery("select ......");
    

    How to make a filter? When I will write smth in QLineEdit, the QListView will refresh with that filter? If I'll make QLineEdit clear, the QListView will show model, that shows basically.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You can use a extra model for that
      http://doc.qt.io/qt-5/qsortfilterproxymodel.html#details

      D 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        You can use a extra model for that
        http://doc.qt.io/qt-5/qsortfilterproxymodel.html#details

        D Offline
        D Offline
        derilshows
        wrote on last edited by
        #3

        @mrjj but how to do that for my widget?

        mrjjM 1 Reply Last reply
        0
        • D derilshows

          @mrjj but how to do that for my widget?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @derilshows said:
          Hi , what you mean with widget?
          you use it with your QSqlQueryModel.

          there is sample on how to use it
          http://doc.qt.io/qt-5/qtwidgets-itemviews-basicsortfiltermodel-example.html

          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