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. Infinite scrolling of a TableView

Infinite scrolling of a TableView

Scheduled Pinned Locked Moved QML and Qt Quick
infinite scrolltableviewdynamic scroll
6 Posts 3 Posters 4.3k 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.
  • T Offline
    T Offline
    tezine
    wrote on last edited by
    #1

    Hi all,
    Is it possible to create a QML TableView with infinite scrolling, so I can load more data into it dynamically when the scroll reaches the end?
    For example, this is possible on a ListView using the code below, but I couldn't find a way to do it on a TableView:
    onAtYEndChanged: {
    if(atYEnd) sigEndOfListReached()
    }
    Thank you,
    Bruno.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes, it can be done in the same way as in all Qt's MVC classes: subclass QAbstractItemModel and reimplement canFetchMore() and fetchMore() methods. It might look scary at first sight, but is really super-easy.

      (Z(:^

      P 1 Reply Last reply
      1
      • T Offline
        T Offline
        tezine
        wrote on last edited by
        #3

        Hi Sierdzio, thank you for the quick response, but that's not the kind of solution I'm looking for.
        I don't want to subclass QAbstractItemModel for each TableView I have (many!). Meanwhile, I just created a navigation bar where the user can move backward/forward manually. :-(
        Thanks again/Bruno.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Nobody forces you to subclass QAbstractItemModel multiple times. Just like ListModel can work on different data, so can the QAbstractItemModel, when applied carefully. As for navigation: QtQuick.Controls have a built-in ScrollBar item, if you are interested.

          If you still want to do it purely in QML, though, here is an idea:

          TableView {
              onCurrentRowChanged: {
                  if (currentRow > (0.9 * rowCount)) {
                      // insert more rows
                  }
              }
          }
          

          (Z(:^

          1 Reply Last reply
          0
          • sierdzioS sierdzio

            Yes, it can be done in the same way as in all Qt's MVC classes: subclass QAbstractItemModel and reimplement canFetchMore() and fetchMore() methods. It might look scary at first sight, but is really super-easy.

            P Offline
            P Offline
            ParCHAT1497
            wrote on last edited by
            #5

            @sierdzio Hi i want to implement something similar... i am not able to fetch the position of scrollbar.. how can I do it ?

            sierdzioS 1 Reply Last reply
            0
            • P ParCHAT1497

              @sierdzio Hi i want to implement something similar... i am not able to fetch the position of scrollbar.. how can I do it ?

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @ParCHAT1497 said in Infinite scrolling of a TableView:

              @sierdzio Hi i want to implement something similar... i am not able to fetch the position of scrollbar.. how can I do it ?

              See the original post by @tezine it includes exact code you need.

              (Z(:^

              1 Reply Last reply
              0
              • C CPPUIX referenced this topic on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved