Although I already figured it out, it took quite a while. If you know a less convoluted solution - please share.
I'd like to provide a custom View that works with any type of model (with arbitrarily named fields):
model: 3model: [ "red", "yellow", "green" ]model: [ {color: "red"}, {color: "yellow"}, {color: "green"} ]model: ListModel{ ListElement{color: "red"}; ListElement{color: "green"} }- subclassed
QAbstractItemModeland such...
To do that I decided to provide a property Component delegate that user would populate with a visual Item that would be inserted deep into my View.
However, the View also needed to access some information from that same delegate because otherwise it would either promote unneeded code duplication, or unneeded complexity of proxy model.
MyView {
mymodel: ["red", "blue"]
mydelegate: Text {
text: "color=" + modelData.name
must_also_somehow_set_color_of_MyView_element_to: modelData.color
}
}
...where MyView should be something like:
Column {
Repeater {
model: mymodel
delegate: Rectangle {
color: somehow_get_color_from_mydelegate
Text {} // <--- instantiate mydelegate here with data from mymodel
}
}
}
Doing so seems easy but a naive attempts didn't work. The solution posted as an answer did for me.