Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Infinite scrolling of a TableView

    QML and Qt Quick
    infinite scroll tableview dynamic scroll
    3
    6
    3397
    Loading More Posts
    • 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
      tezine last edited by

      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 Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        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 Reply Quote 1
        • T
          tezine last edited by

          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 Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            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 Reply Quote 0
            • P
              ParCHAT1497 @sierdzio last edited by

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

              sierdzio 1 Reply Last reply Reply Quote 0
              • sierdzio
                sierdzio Moderators @ParCHAT1497 last edited by

                @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 Reply Quote 0
                • Referenced by  Abderrahmene_Rayene Abderrahmene_Rayene 
                • First post
                  Last post