Hi Guys,
I want to display N horizontal lists. I put listview inside of repeater. N is a number of lists and it depends on some data in C++. Each list has its own model. I don't know how to properly register model for each list. Here is some sketch of code:
Column {
Repeater {
model: ?? // This number (number of lists) depends on some data in C++
Rectangle {
ListView {
orientation: ListView.Horizontal
model: ?? // There will be more than one list --> Question: How to assign different models to list
delegate: Rectangle {
Text {
text: somemodelproperty
}
}
}
}
}
}
Column {
Repeater {
model: ?? // This number (number of lists) depends on some data in C++
Rectangle {
ListView {
orientation: ListView.Horizontal
model: ?? // There will be more than one list --> Question: How to assign different models to list
delegate: Rectangle {
Text {
text: somemodelproperty
}
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
I've found something like this:
property var subModels: [m1, m2, ... m10]
Then for the ListView inside the repeater delegate you can:
ListView {
model: subModels[index]
// ...
}
but here is specific number of models, and I don't how how many of them I'll have.
In C++, I have implemented QList <DataClass> list, and each list is "bounded" to a ListView by doing something like that:
QQmlContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &serviceList);
Registering one model for one listview is just fine and it's working.
Bookmarks