I am trying to deploy my application on Android (version 4), but I have problem with delegates in models - ReferenceError: modelData is not defined
.
My code is
MapItemView {
model: roadModel
delegate: MapPolyline {
line.width: 3
line.color: "red"
path: [
modelData.fromWaypoint,
modelData.toWaypoint
]
}
}
This code should connect two points on Map
component.
Everything works on GCC Ubuntu 16, but when I try to deploy it on Android, modelData
just stop working and is undefined.
How can I make modelData
work again?
Thank you for your help!
modelData
is only defined for "dumb" models, the ones without roles like a QStringList, a JavaScript array, an integer, ...
It acts like if the model had a single role named modelData
For QAbstractListModel
(a custom c++ one, or a ListModel
), the model has a list of roles, you use them to access model data in a delegate.
In your case, it should be fromWaypoint
or with the model qualifier (model.fromWaypoint
) if you want to avoid shadowing and be explicit.
The relevant doc is here : http://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#models