[Interest] Overhead for QObject based data models in QML

Preet prismatic.project at gmail.com
Sat Dec 28 03:44:07 CET 2013


One of the ways to pass dynamic data to QML is by using a list
QObjects. So if you had a QAbstractItemModel with QObject* elements,
you could pass it to QML and have the corresponding QML view
automatically update when the list changes and when an element in the
list changes.

I'm concerned about what kind of overhead this incurs when I have a
fairly large list (say 100's of elements). It seems like creating that
many QObjects probably isn't a good idea.

For example, think of a file browser application, and loading a folder
with hundreds of files. You need to dynamically update both the list
itself (say someone copies or removes a file in the folder elsewhere)
*and* the elements themselves (maybe a file is being created and its
file size is changing, or its been modified and its timestamp has
changed), etc.

I know QML only draws necessary delegates in the view so its not
rendering cost I'm worried about, but the memory and processing
overhead might be a concern (or it might not -- maybe creating that
many QObjects isn't a big deal but I don't know so I'm asking here).

Any thoughts or recommendations for design patterns for the
aforementioned scenario?


More information about the Interest mailing list