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. incremental loading without total count information
Qt 6.11 is out! See what's new in the release blog

incremental loading without total count information

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

    i'm wondering whether it is possible to implement incremental data loading in views without knowing the total number of results in advance?

    1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      QAbstractbModel has fundamental fetchMore(), https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore, and for example the QSql models implement this 256 rows at a time. So incremental loading is going on regardless of row count.

      You can leverage that in your views. "Paging" can fetch the next block of rows.

      U 1 Reply Last reply
      1
      • JonBJ JonB

        QAbstractbModel has fundamental fetchMore(), https://doc.qt.io/qt-5/qabstractitemmodel.html#fetchMore, and for example the QSql models implement this 256 rows at a time. So incremental loading is going on regardless of row count.

        You can leverage that in your views. "Paging" can fetch the next block of rows.

        U Offline
        U Offline
        user4592357
        wrote on last edited by
        #3

        @JonB
        for fetchMore() to work, i need to implement canFetchMore() which means i need to know whether there's more data available or not?
        how will data() be called for model index, if rowCount() is not known?

        JonBJ 1 Reply Last reply
        0
        • U user4592357

          @JonB
          for fetchMore() to work, i need to implement canFetchMore() which means i need to know whether there's more data available or not?
          how will data() be called for model index, if rowCount() is not known?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @user4592357
          You only have to know if there is more data to fetch, not how many total there is. But in any case I assume you can have canFetchMore() return true while you don't know, and only in fetchMore() do you do the next fetch and discover whether there was any more.

          If a QModelIndex is for row not yet fetched, you can have data() fetch more to resolve the reference if necessary. You wouldn't have to know the final rowCount() up front.

          1 Reply Last reply
          1

          • Login

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