[Qt-interest] Huge amount of data in tree or whatever(view)
Sean Harmer
sean.harmer at maps-technology.com
Thu Dec 31 23:30:03 CET 2009
Hi,
Louai Al-Khanji wrote:
> The model/view classes will do much of this for you. In your model,
> reimplement rowCount() to return the total number of entries. Your
> data() function will then be called for those entries that are
> visible.
>
> Depending on your requirements and implementation, you might choose to
> do some sort of caching or optimisation, like getting the surrounding
> entries at the same time in one request when the data function is
> called.
In fact this is already covered by the QAbstractItemModel API. Check out
the functions:
bool canFetchMore ( const QModelIndex & parent ) const
void fetchMore ( const QModelIndex & parent )
and the ItemViews/Fetch More example application that ships with Qt.
The above should show you how to customise your model so that the model
gets populated in a lazy fassion when the data is actually needed.
To speed up the actual drawing of your 1.5 million items in the
QTreeView you should also call setUniformRowHeights( true ). This means
that the view does not have to query the height of each and every row in
order to be able to calculate the scale of the scroll bars. This can
have a massive performance increase - if your rows really are of uniform
height.
Happy New Year!
Sean
More information about the Qt-interest-old
mailing list