modelData and ListView
-
I have this
ListView{}element and inside of it there isComponentwith atitleproperty. For that title they havemodelData.labelset:ListView { ... Banner { title: modelData.label } }Can I assume that
modelDatais reffering to theListView'smodelproperty? When I right click themodelData.labeland select: "Follow symbol under cursor" it takes me nowhere. The actualmodelproperty for theListViewis being set to some value in the business logic.I guess what I am trying to ask is, if I create a
ListViewcan I refer to it asmodelDataor is it a bad idea for me to assume that thismodelDatabelongs 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.
-
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.