On 18.04.2016 13:57, Andrea Bernabei wrote: > > > On Mon, Apr 18, 2016 at 12:43 PM, Alberto Mardegan > <alberto.marde...@canonical.com <mailto:alberto.marde...@canonical.com>> > wrote: > > 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. :-) > > > Does ListView reuse delegates? > As far as I know, it creates new ones on the fly, every time. > > I guess Omar's solution was for cases where: > - you have fixed delegate height > - you have a fixed and known number of delegates > - you want to avoid instantiating all of them at once > > in that case reusing the delegates could work better than recreating > them like ListView does. > > If I'm wrong and ListView already reuses delegates instances, then my > points above are of course void.
AFAIK I think too that the ListView does not reuse them but instead always destroys/creates them when they leave/enter the cacheBuffer zone. > > > Ciao, > Alberto > > -- > Mailing list: https://launchpad.net/~ubuntu-phone > Post to : ubuntu-phone@lists.launchpad.net > <mailto:ubuntu-phone@lists.launchpad.net> > Unsubscribe : https://launchpad.net/~ubuntu-phone > More help : https://help.launchpad.net/ListHelp > > > >
signature.asc
Description: OpenPGP digital signature
-- Mailing list: https://launchpad.net/~ubuntu-phone Post to : ubuntu-phone@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntu-phone More help : https://help.launchpad.net/ListHelp