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. QML "infinite" ListView
Forum Updated to NodeBB v4.3 + New Features

QML "infinite" ListView

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 3 Posters 9.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.
  • I Offline
    I Offline
    Ices_Eyes
    wrote on last edited by
    #3

    Ok, so... I will try to investigate on this solution, let's see what sort of mess I can make... :P

    PS: any idea on how to detect that the user has scroll to the end of the list? :)

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raaghuu
      wrote on last edited by
      #4

      this could be done by using the valueChanged signal of the scroll bar
      [quote author="Ices_Eyes" date="1340693731"]PS: any idea on how to detect that the user has scroll to the end of the list? :)[/quote]

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Ices_Eyes
        wrote on last edited by
        #5

        [quote author="raaghuu" date="1340694509"]this could be done by using the valueChanged signal of the scroll bar
        [/quote]

        Any more hint about the scroll bar? :P

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Ices_Eyes
          wrote on last edited by
          #6

          [quote author="Ices_Eyes" date="1340694878"]
          [quote author="raaghuu" date="1340694509"]this could be done by using the valueChanged signal of the scroll bar
          [/quote]

          Any more hint about the scroll bar? :P[/quote]

          I think I found another solution... Could this be acceptable? :)
          On the ListView element:
          @onMovementEnded: {
          if(atYEnd) {
          console.log("End of list!");
          }
          }@

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raaghuu
            wrote on last edited by
            #7

            QScrollBar... the QWidgets which implement scroll bar automatically inherit horizontal/verticalScrollBar() functions from QAbstractScrollArea...these return QScrollBar* of the widget... QScrollBar emits valueChanged(int) signal which can be checked with QScrollBar::maximum(), inherited from QAbstractSlider. maximum() gives the maximum value of the slider(i.e., the end value)... you can connect this signal to a slot which loads new content...this would definitely work(probably with a little tweaking and the help from docs)

            1 Reply Last reply
            0
            • R Offline
              R Offline
              raaghuu
              wrote on last edited by
              #8

              oh QML...sorry...my bad...cancel the previous posts

              1 Reply Last reply
              0
              • R Offline
                R Offline
                raaghuu
                wrote on last edited by
                #9

                although there would be a similar mechanism in qml too, i'm sure... take a look at the docs...you'll find it

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  Ices_Eyes
                  wrote on last edited by
                  #10

                  [quote author="raaghuu" date="1340696534"]oh QML...sorry...my bad...cancel the previous posts[/quote]

                  LoL! Well, ok... In fact I was thinking on how to do that without C++ code... :P

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    raaghuu
                    wrote on last edited by
                    #11

                    you could use the currentIndex property of ListView and when it reaches the end, you could add items to the list...
                    P.S. i just started qml a few days back(though i've been at Qt-c++ for quite some time now), so i don't know much...but this seems like a solution...do tell if this works :)

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      Ices_Eyes
                      wrote on last edited by
                      #12

                      I think I manage to make all work like I want :P

                      Advice or comment are really appreciated :)

                      @
                      UpdatableXmlListModel.qml
                      import QtQuick 1.1

                      ListModel {
                      id: root
                      default property alias roles: xmlListModel.roles
                      property alias source: xmlListModel.source
                      property alias query: xmlListModel.query
                      property alias namespaceDeclarations: xmlListModel.namespaceDeclarations

                      property alias status: xmlListModel.status
                      
                      function push(item) {
                          append(item);
                      }
                      
                      property variant __xmlListModel: XmlListModel {
                          id: xmlListModel
                      
                          property variant keys: []
                          onSourceChanged: {
                              console.debug(source)
                          }
                      
                          function appendItem(index, count) {
                              for (var i = 0; i < count; i++) {
                                  var item = get(i + index);
                                      push(item);
                              }
                          }
                      
                          onItemsInserted: appendItem(index, count)
                      }
                      
                      Component.onCompleted: {
                          var keys = new Array()
                          for (var i = 0; i < roles.length; ++i) {
                              if (roles[i].isKey) {
                                  keys.push(roles[i].name);
                              }
                          }
                          xmlListModel.keys = keys;
                      }
                      

                      }@

                      @NewsList.qml

                      ....

                      UpdatableXmlListModel {
                      id: newsModel
                      query: "/root/item"

                      XmlRole {
                          name: "id"
                          query: "id/string()"
                      }
                      XmlRole {
                          name: "title"
                          query: "title/string()"
                      }
                      XmlRole {
                          name: "thumb"
                          query: "thumb/string()"
                      }
                      XmlRole {
                          name: "pubDate"
                          query: "pubDate/string()"
                      }
                      
                      onStatusChanged: {
                          ....
                      }
                      

                      }@

                      :D

                      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