Is an QAbstractListModel
implementation with say roles
name, image, enabled, color, editable
Better than an implementation with a single role (forgive me for not being able to come up with a better name)
thing
which causes a QObject*
with aforementioned Q_PROPERTY
s to be returned?
The difference on QML side would be an extra "indirection" when accessing the values in say, a delegate:
model.thing.name
vs
model.name
I lean towards the QObject approach, because it disentangles the data view from the list model, and has a potential for reuse. It also doesn't require you to also implement the setData
function. As far as I can tell, there are no specific pro's for the "many roles" option, unless of course it's impossible to properly define a proper QObject
subclass wrapping the data (because e.g. it could make little sense conceptuallyfor specific cases).