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. Is QTableView using lazy population?
Forum Updated to NodeBB v4.3 + New Features

Is QTableView using lazy population?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.3k 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.
  • G Offline
    G Offline
    giowck
    wrote on last edited by
    #1

    Hi,

    I have a model which gets its data from a sqlite database with many many entries, here I implemented my custom model, where every QModelIndex creation is associated with a SQL query.

    Now my question is:
    What happens when I set the my model on a QTableView?
    Are all entries (indexes) loaded at once or only the visible entries (rows)? Like on Android with its cursors...

    In other words:
    Does each item delegate load the respective index only if currently visible (lazy loading)?

    Thank you!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giowck
      wrote on last edited by
      #2

      Just found this discussion on the mailing list: http://lists.trolltech.com/qt-interest/2007-05/thread01132-0.html

      seems to confirm that a QTableView queries only the indexes that are actually visible on the viewport area.

      Is that right?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Yes, that is correct. The view only queries what it needs to paint.

        QSqlTableModel (possibly QSqlQueryModel) also does lazy loading in blocks of 256 (maybe 255) rows. So, if you have many rows you will experience short model-induced delays as you scroll into new territory. If normal use dictates, and memory permits, you can force it to load using QAbstractItemModel::canFetchMore() and QAbstractItemModel::fetchMore() and after that scroll is much less interrupted.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giowck
          wrote on last edited by
          #4

          I'm not using the QSqlTableModel or any other existing SQL model because my model queries data from SQL table joins and unions, which are not supported by those models (read only).

          So i'm going to use a custom model which uses QSqlQuery as its base or subclass QSqlQueryModel to add write methods...

          Thanks

          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