I have a question about rectangle, thanka!
-
in my program , when first run the program ,the rectangle read the listmodel's data.
i want to click the button in the rectangle to reste the data that rectangle readed.
how to make it?
for example:
Rectangle{
Rectangle{
x: get(0).listmodel.x
y:get(0).listmodel.y
}
Button{
// reset the x and y ,how to do it?
}
} -
Hi,
Can you explain what do you mean by reset ? Do you want to default it to 0 ?
Then just access the Rectangle using its id and set X and Y to 0. -
i mean :in listmodel ,every element save a group x and y coordinate.
when program first running,Rectangle :get(0).listmodel.x y:get(0).listmodel.y.
then i press button , so Rectangle :get(1).listmodel.x y:get(1).listmodel.y.,acquire new x and y coordinate. -
Well then you can use the "contentItem":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-flickable.html#contentItem-prop and get the childrens and then access its x and y.
E.g
@
listview.contentItem.children[1].x
listview.contentItem.children[1].y
@This gives the item a index 1 in ListView.