I have two additional suggestions:
First, for one use, pass an identifier, as basically a pointer to an element:
MouseArea { id: myClicker; onClicked: { callFunc (myClicker); } }
Then, if you need several elements to share this behavior, this means that you are using MVC so that the identifier works exactly the same:
Repeater { model: 100; delegate: MouseArea { id: myClicker; onClicked: { callFunc (myClicker); } } }
This is the classic part.
But in order to do even better, if you create your own components, keep in mind to create the property "self" helper, which correctly does the work of 'this':
MouseArea { // component root definition id: base; property var self : base; // bind self on the I }
Then use it as follows:
Repeater { model: 100; delegate: MyComponent { onClicked: { callFunc (self); } } }
Use it as often as you want!
source share