I have a grid with nested elements(text and mouse area within a rectangle):
property variant colorArray: ["#00bde3", "#67c111", "#ea7025"]
...
Grid{
rows: 5
columns: 5
spacing: 5
anchors.centerIn: parent
Repeater{
id: gridRect
model: 25
Rectangle{
id: rect
width: 50
height: width
color: "white"
radius: 5
Text {
id: tttt
anchors.centerIn: parent
color: "lightBlue"
text : index
}
MouseArea{
anchors.fill: parent
}
}
}
}
and I want to change the color of some squares and texts within the grid randomly but I don't know how to access them, I tried using timers like this:
Timer {
id: alfa
interval: 500; running: true; repeat: true
onTriggered: {
/*if random square not white , a color from color array is picked to change it
else random square.color = "white"*/
}
}
Timer {
id: beta
interval: 1000; running: true; repeat: true
onTriggered: {
//changes the text of a random tttt element in the grid
}
}
I tried many things but it all failed, like using property binding seemed to change the whole grid color & text not a single square, I can't understand how to access nested elements and repeaters children at all and the documentation isn't helping what should I do?