PDA

View Full Version : canFetchMore() direction?



RolandHughes
22nd October 2014, 00:17
In looking through the doc it seems canFetchMore() will be called any time hits the "end" of the data it has to display. What isn't clear is how one tells which direction the table is attempting to move. When one has a limited viewport, say 30-100 rows, windowing over a database which is gigs in size, how does canFetchMore() in the model determine which direction it should be checking? I assume the same test will work when fetchMore() is called so it nows which direction to fetch data.

wysota
22nd October 2014, 07:56
fetchMore() is meant to grow the model "downwards" (to higher row indices). There is no infrastructure in QAbstractItemView that would require the model to grow "upwards" as it is assumed that when the model is populated, the view shows the beginning of data. When the view is scrolled, the data already populated is kept in memory. What you can do is to provide your own internal cache in the model, only keeping a window of data large enough to populate the view and generate data on the fly as the window (centered around the last accessed index in the model) moves.