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. (QtableView or QTreeView ) Vs (QTableWidget and QtreeWidget)
QtWS25 Last Chance

(QtableView or QTreeView ) Vs (QTableWidget and QtreeWidget)

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.8k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I want to know does QtreeView fetches data from model only for visible rows in the windows
    If we have QtableView or QTreeView if we have 1000 rows in model and if only 50 rows are visible at one tine does QTreeView/QtableView only fetches data for 50 rows only

    Also for Storage part I assume the QTreeWidget /QtableWidget stores data for all the rows but QTReeView/QtableView does not store any data

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Neither Q*Widget nor Q*View store data. They both use models for it. Q*Widget classes inherit Q*View ones.
      The difference is that Q*Widget classes have a built-in customized model that is pretty much equivalent to Q*View using QStandardItemModel (with minor bells and whistles).

      As to what is queried when depends on the model and some view settings. "data" is not only the visible part (like text or color of a cell), but also things like size hint. While some data types will be queried only for the visible items, some others might be queried for all.

      For example to properly calculate position and ranges of the scroll bars all cells need to be asked for their size, whether they are visible or not. There are some view settings that can help optimize this, e.g. uniformRowHeights.

      Also, a model can implement certain optimizations too. One example is canFetchMore() method. With it the model will report that it has only some limited subset of rows. When the view scrolls near the bottom the view will call canFetchMoreand fetchMoreto make the model dynamically load more data.

      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