[Qt-interest] Model/View delayed loading for large datasets

william.crocker at analog.com william.crocker at analog.com
Thu Feb 4 13:02:04 CET 2010



Jugdish wrote:
> Stepped through this with a debugger and found the culprit: 
> QTreeView::doItemsLayout() which calls QTreeViewPrivate::layout(int) 
> has this block of code:
>
> for (int j = first; j < first + count; ++j) {
>     current = model->index(j - first, firstColumn, parent);
>     if (isRowHidden(current.sibling(current.row(), 0))) {
>         ++hidden;
>         last = j - hidden + children;
>     } else {
>         ...
>     }
> }
>
> So it's iterating over every row of the first column, checking if the 
> row is marked as hidden. I don't really see anyway to avoid this being 
> called unless I want to completely override the layout the management 
> of QTreeView, which would be a pain.
>


Yes. But who is forcing you to "fetch more data from the data base" 
which was your
original complaint. And if isRowHidden() *does* interact with the 
underlying model, I
assume you have written your own. Especially see:

    QAbstractItemModel::hasChildren()

and familiarize yourself with the tricks regarding the "has children" 
(plus sign)
indicator.

Some of the above is a guess.

Bill


> On Wed, Feb 3, 2010 at 2:11 PM, william.crocker at analog.com 
> <mailto:william.crocker at analog.com> <william.crocker at analog.com 
> <mailto:william.crocker at analog.com>> wrote:
>
>
>     Follow the code execution in a debugger and see what it is doing.
>



More information about the Qt-interest-old mailing list