[Interest] Can a view somehow notify a model of which rows it is going to show on screen?

Andre Somers andre at familiesomers.nl
Tue Apr 22 21:38:54 CEST 2014


Mark Gaiser schreef op 20-4-2014 4:04:
> Hi,
>
> the title says it all...
>
> I can't find any signals that expose this information in the model.
> I would like to know this from the QML ListView component. What i can
> do is tell the model where the current y position is in the models
> content and the height of each row. That gives me enough information
> to calculate which rows are visible, but i'm hoping there is "some"
> way out there that i just haven't discovered yet.
>
> I'm asking because i have a big dataset and only want to sort the data
> that is visible for the user (partial_sort along with nth_element will
> do that).
AFAIK, there are no facilities for that. The way to know what data is 
needed, is simply to respond to the data() calls in QAbstractItemModel. 
Only rows that are needed are (should be) fetched. But that information 
is not shared in advance.

Are you sure that this is your performance bottleneck though? To me, it 
sounds like premature optimization to worry about this and to try to 
optimize this.

André





More information about the Interest mailing list