Get repeater elements to give them a specific script
-
I have a few rectangles that I created with a repeater. Those rectangle are going to use a mouse area to add actions to each one. But my problem is that I don't know how to give each one a different action ( call different method, or call with specific properties...)
Does anybody can help me with this ?Thank you in advance
-
Hi, do you mean something like this:
Column { anchors.centerIn: parent spacing: 4 Repeater { model: 4 Rectangle { id: rect width: 100 height: 100 color: "black" property var func MouseArea { anchors.fill: parent onClicked: rect.func() } } onItemAdded: { if (index % 2) item.func = function () { console.log("function 1 called."); } else item.func = function () { console.log("function 2 called."); } } } }