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. QAbstractTableModel data preloading
Forum Updated to NodeBB v4.3 + New Features

QAbstractTableModel data preloading

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 672 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.
  • T Offline
    T Offline
    Trigve
    wrote on last edited by
    #1

    Hi,
    I'm trying to show large data set in QTableView. Now, I want to preload the data for the all visible rows, instead of reading the data row by row. I've searched the docs but couldn't find the function/signal which could be used. Is something like this possible with QAbstractTableModel or do I need to make the custom QTableView?

    Thanks

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

      Hi
      There is FetchMore
      https://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trigve
        wrote on last edited by
        #3

        Hey @mrjj ,
        thanks for the quick reply.

        I have somehow missed the canFetchMore()/fetchMore(). Now, can I somehow find out which rows and columns are currently visible so I can load the data?

        mrjjM 1 Reply Last reply
        0
        • T Trigve

          Hey @mrjj ,
          thanks for the quick reply.

          I have somehow missed the canFetchMore()/fetchMore(). Now, can I somehow find out which rows and columns are currently visible so I can load the data?

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

          @Trigve
          Hi
          Well the view call canFetchMore() when it needs more data
          so not sure you need to manually care about what is visible or not.
          As far as I know, if you implement
          https://doc.qt.io/qt-5/qabstractitemmodel.html#canFetchMore
          and
          https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore

          Then it just works :)

          1 Reply Last reply
          1
          • T Offline
            T Offline
            Trigve
            wrote on last edited by
            #5

            @mrjj
            But how do I know how many rows do I need to preload? In the link you posted, the items are loaded in 100 increments. So I may do the same, but this could be ineffective because instead of 1 preload of the all the data I need, I would make 2-3 depending of the height of the view.

            Anyway, thanks for the help.

            mrjjM 1 Reply Last reply
            0
            • T Trigve

              @mrjj
              But how do I know how many rows do I need to preload? In the link you posted, the items are loaded in 100 increments. So I may do the same, but this could be ineffective because instead of 1 preload of the all the data I need, I would make 2-3 depending of the height of the view.

              Anyway, thanks for the help.

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

              @Trigve
              Well You could use
              https://doc.qt.io/qt-5/qabstractitemview.html#visualRect
              to check if they are shown if you want to optimize that much.
              Im not sure how to easy check how many lines visible but
              but if you are using fixed row height then its easy to calc with
              viewport height and item height.

              1 Reply Last reply
              1
              • T Offline
                T Offline
                Trigve
                wrote on last edited by
                #7

                @mrjj
                Ok, will try that.

                Thanks again :)

                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