[Qt-interest] Model/View delayed loading for large datasets
Andre Somers
andre at familiesomers.nl
Mon Feb 1 16:09:09 CET 2010
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.
>
> Thank you!
Yes, you can do this!
Take a look at QAbstractItemModel::canFetchMore and ::fetchMore.
André
More information about the Qt-interest-old
mailing list