ListView with VisualItemModel
-
Hi everyone,
I'm using a VisualItemModel for a listView. for example
@ListView{
id:myList
height:??????
width:360
model:myModel
}
VisualItemModel{
id:myModel
Rectangle{
id:myRec
width:360
height:40
}
}@As you can see above, i want the list view'height is equal to the model's height, specially to the myRec'height(40), in the example.
So my question is : how can we do a property binding between a listView and its VisualItemModel?
Thanks in advance
-
Andre, you are great!!! Wrote what I was writing :)
-
yes,
in the VisualItemModel.qml, we add a property to the model
@VisualItemModel{
id:myModel
property real myHeight:myRec.height
Rectangle{
id:myRec
width:360
height:40
}
}@and in the view.qml, we create an instance of visualItemModel, and bind the two heights
@ListView{
id:myList
height:myModel.myHeight
width:360
model:myModel
VisualItemModel{
id:myModel
}
}@ -
Thanks! I am doing some stuff on lists and it is almost useful as an example.