First of all I am glad that you found a solution you're happy with.
Nevertheless, I still recommend to use GridView. On the one hand, it probably reduces your amount of code, on the other hand, and most importantly, it's much more readable to you and every other developer, who might want to help you or needs some Inspiration, because he has the same problems as you have.
To your question:
On of the key features of Qml is property binding. So let's say you have
import QtQuick.Controls 2.3
ApplicationWindow {
id: root
width: 600; height: 600
visible: true
Rectangle {
width: parent.width/2; height: parent.height/2
color: "blue"
}
MouseArea {
anchors.fill: parent
onClicked: { root.width -= 10; root.height += 10; }
}
}
If you click the applicationWindow its width will be decreased by 10 and its height increased by 10. At the same time the rectangle's width will be decreased by 5 and its height increased by 5. That's because its size depends on the size of the applicationWindow and will be changed automatically.
Same applies to your case. If the model changes its size, your ListView should notice this and update the list.
Just in case you don't know (or if it's working in your case, didn't know how your model looks like) you can do:
model: yourModelName.length
or if it's a List of Arrays/Vectors
model: yourModelName[index].length
Index should be available through the outer ListView if I did understand you correctly.
ListView {
model: yourModel.length
delegate: ListView {
model: yourModel[index].length
}
}
Probably there is no need to write an "getLengthOfDataVector" function, if you intended to do it like this. But maybe I missed something as I don't know how you model looks like exactly.