I am trying to understand how one would choose whether to use a QAbstractListModel
or a QObject
with a QQmlListProperty
.
Given that the QQmlListProperty
handles the "roles" functionality that would have to be written using the QAbstractListModel
, it seems like the less tedious route.
I can't tell if most people suggest using QAbstractListModel
simply because it has been around longer or if it is the better choice for some reason.
Nor have I been able to find any discussion of the trade-offs between the two options. This question was brought up during a Qt Developer Days talk discussing QAbstractListModel
, but the answer was along the lines of "that would also work".
A model implementation will generally be more efficient to work with a view. When you expose a "dumb list" to use a model, every time the model changes the whole view is reconstructed, whereas with a model only the changes are updated. If you have a lot of items there will be tangible performance overhead.
You could use a list for a model, and you could use a model for a list, but when you want optimal performance, you should use a list for a list, and a model for a model.