← Back to team overview

ubuntu-phone team mailing list archive

Re: POC: Recycling ListView items

 

On 18/04/2016 13:57, Omer Akram wrote:
> While working on a pet project[1] for the Phone, an issue that I faced
> was stuttering scrolling in listviews. QML tips page[2] suggested to use
> Flickable+Column+Repeater combination to have smooth scrolling, that
> worked and is currently what I have implemented in my app but I always
> thought that was not the perfect solution.
> 
> With some knowledge of how Android ListView works and its mechanism of
> recycling ListView items, I wrote a hack[3] to achieve something similar
> in QML.
[...]

You are trying to reinvent the QML ListView :-)
The QML ListView recycles the delegates, and this behaviour is partially
configurable via the cacheBuffer property:

  http://doc.qt.io/qt-5/qml-qtquick-listview.html#cacheBuffer-prop

Now, this means that when scrolling a listview, occasionally the
delegates need to be either created (the first time they are used) or
reused (which causes a reassignment of their properties based on the
model data).
Both these operations can be expensive, that's why someone gave the tip
of using a Column+Repeater when the number of delegates is low and
doesn't change, so that the whole list is created only once and
scrolling will be smooth.

If now you found that this tip doesn't work well for you (typically
because of high memory consumption if the model has many items), it
means that you should go back to using a ListView. :-)

Ciao,
  Alberto


Follow ups

References