Master - Detail in QML ListViews. A ListView with a delegate with another ListView.
I have a ListView (A) that on it's delegate has another ListView (B). How can (B) objects change when the user changes from one item to another in (A)?
For exemple:
Imagine that I have a list of persons, and every person has a list of cars:
- Person1 - car1, car2, car3
- Person2 - car4
- Person3 - car5, car6, car7, car8
- Person4 - car9, car10
...
The QML has a ListView (A) that it's delegate has another ListView (B). The parent ListView (A) shows the Person data, and the detail ListView (B) must show the cars of that person.
Code:
// A ListView
ListView {
model: personModels
delegate: Row {
Text {
text: model.name
}
Text {
text: model.street
}
...
// B ListView
ListView {
model: ????
delegate: Row {
Text {
text: model.carColor
}
}
}
}
}
The problem is that the second ListView must change the model for every item in ListView A.
How can I do it?
Re: Master - Detail in QML ListViews. A ListView with a delegate with another ListVie
You need a property in "personModels" that contains the cars for that person.
Then you can just write something like
What's the type behind "personsModels"?
Cheers,
_
Re: Master - Detail in QML ListViews. A ListView with a delegate with another ListVie
Yes, it work's, but in the QML can't put model., it gives error.
It must be:
Cheers