[Qt-qml] ListView (optimization flags)
Adriano Rezende
adriano.rezende at openbossa.org
Fri Feb 4 16:04:18 CET 2011
Hi,
While comparing the QML ListView performance with an old ListView of
mine (http://qt.gitorious.org/~arezende/qt-labs/arezende-clone/blobs/master/shared/listview.cpp),
it's clear that in 'low end' devices (X6/N97/5800) the QML ListView is
not smooth as it could be.
I didn't take any benchmark, but looking at the code I've saw a
possible culprit; In the current implementation the delegate items are
constantly being destroyed and recreated while scrolling the list, and
the cacheBuffer property just postpone the problem and is not scalable
for huge lists.
In my implementation I just reuse the items, switching them like a
carousel. The items are being kept alive and erased before reuse (when
needed).
Probably the QML ListView is implemented that way to ease the
developer work. But in most of the use cases the delegates does not
create items dynamically inside them, so they could be reused even
without any clean process. For the rare cases where a clean is needed,
an "indexAboutToChange" signal could be provided.
It would be nice if an optimization flag were provided like the following:
ListView {
recycle: true
delegate: listDelegate
}
Component {
id: listDelegate
Item {
onIndexAboutToChange: {
// clean dynamically created items if needed
}
}
}
This recycle property would be more powerful than cacheBuffer property
and would also be scalable.
I didn't look deeply at the QML ListView, so my assumptions could be
wrong. Someone with a deeper knowledge of the ListView source code
would like to discuss this?
Br,
Adriano
More information about the Qt-qml
mailing list