modelData and ListView
-
I have this
ListView{}
element and inside of it there isComponent
with atitle
property. For that title they havemodelData.label
set:ListView { ... Banner { title: modelData.label } }
Can I assume that
modelData
is reffering to theListView
'smodel
property? When I right click themodelData.label
and select: "Follow symbol under cursor" it takes me nowhere. The actualmodel
property for theListView
is being set to some value in the business logic.I guess what I am trying to ask is, if I create a
ListView
can I refer to it asmodelData
or is it a bad idea for me to assume that thismodelData
belongs to it's parentListView
? -
It depends on your model. From:
https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html
Models that do not have named roles will have the data provided via the modelData role. The modelData role is also provided for models that have only one role. In this case the modelData role contains the same data as the named role.
If your model has roles, you could use just the role name, "label", or "model.label" to avoid ambiguity.