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. Listmodel with Search or filter option In QML?

Listmodel with Search or filter option In QML?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 3.2k 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.
  • E Offline
    E Offline
    eswar
    wrote on last edited by
    #1

    In that program consists of textfield and below that listview. The data is obtained from the listmodel and displayed in the listview. The selected list data will be appear in the textfield. If I filter the listview based on the text entered in the textfield appear below the textfield. so, I need logic for filter or search in listview based on the entered data in the textfield in QML.

    raven-worxR 1 Reply Last reply
    0
    • E eswar

      In that program consists of textfield and below that listview. The data is obtained from the listmodel and displayed in the listview. The selected list data will be appear in the textfield. If I filter the listview based on the text entered in the textfield appear below the textfield. so, I need logic for filter or search in listview based on the entered data in the textfield in QML.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @eswar
      QML supports C++ models.
      Thus the most effective way is to subclass QSortFilterProxyModel and register the subclass to QML.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • E Offline
        E Offline
        eswar
        wrote on last edited by
        #3

        Hi @raven-worx

        Thank you for your reply. I already go through that. Any other option in QML itself?

        raven-worxR 1 Reply Last reply
        0
        • E eswar

          Hi @raven-worx

          Thank you for your reply. I already go through that. Any other option in QML itself?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @eswar
          no QML is rather limited regarding creating models, and thats good IMHO.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          E 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @eswar
            no QML is rather limited regarding creating models, and thats good IMHO.

            E Offline
            E Offline
            eswar
            wrote on last edited by
            #5

            @raven-worx Thanks for your quick reply..

            1 Reply Last reply
            0
            • S Offline
              S Offline
              samakkon
              wrote on last edited by
              #6

              One hack to make this in QML is to set the delegate visibility and height based on a filter i.e. something like:

              visible: RegExp(txtField.text,"i").test(name)
              height: visible ? 20 : 0

              where name is the listmodel field you wan't to filter. But as said this is a hack not a proper solution.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                eswar
                wrote on last edited by
                #7

                @samakkon Oh. Ok...Thanks

                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