[Qt-interest] Model/View delayed loading for large datasets
Sean Harmer
sean.harmer at maps-technology.com
Mon Feb 1 16:07:01 CET 2010
Hi,
On Monday 01 February 2010 14:57:20 Jugdish wrote:
> I'm using Qt's model/view framework to implement a tabular display of data
> fetched from an SQL database. The dataset is large enough that it is not
> practical to populate the table with all the data at once. At the same
> time, I'd like to avoid the use of pagination to break up the results into
> pages (end-users have expressed a distaste for this method of navigating
> through the data).
>
> So I'd like to implement an efficient method of loading the data
> incrementally so that only the data currently visible in the viewport is
> actually fetched from the database. First, the total item count would be
> determined from the database. The viewport's scrollbars would be sized
> based on this number, but the actual data (and model indexes) would not be
> loaded until the user scrolls to a particular offset in the viewport. What
> I'm wondering is if this idea is even possible using Qt's model/view
> framework.
Yes this is possible. Check out the itemviews/fetchmore example that ships
with Qt to see how to do it. Hint: it uses the
QAbstractItemModel::canFetchMore() and QAbstractItemModel::fetchMore()
functions.
They should provide a suitable interface for you to implement what you
describe.
Good luck,
Sean
More information about the Qt-interest-old
mailing list