Important: Please read the Qt Code of Conduct -

(QtableView or QTreeView ) Vs (QTableWidget and QtreeWidget)

  • 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

  • Moderators

    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.

Log in to reply