[Solved] Accessing Repeater model in delegate
-
Is there a way to access a Repeater's model in a delegate as you can with ListViews? For example:
@Repeater {
model: cppModel
delegate: MyComponent {}
}// in MyComponent.qml
Rectangle {
id: wrapper
...
Button {
onClicked: // want to directly access the C++ model here rather than have to send a signal to parent component
}
...
}@I've tried what has worked for ListViews...namely:
@wrapper.Repeater.view.model.someSlot()@ -
It's been a while but I'll update what I ended up doing for anyone else interested...
The reasoning behind trying to do the above was mainly that I wanted as little coupling as possible between the view (in this case a Repeater) and the delegate. Since I'm reusing my delegates in several views I didn't want to use a set view id. So basically I just provided the model as a property of the delegate component. Basically something like this:
@
Repeater {
model: cppModel
delegate: MyComponent {
delegateModel: cppModel
}
}
@