this is an attribute related to the QML object, but its scope is local and does not reach the scope of the children.
Instead
an object can be transferred idfrom anywhere within the scope of the component in which it is declared. Therefore, the identification value must always be unique within the scope of the component.
for example: In the following code, it is noted that this in the second element refers to point 2 not to element 1.
Item{
id: item1
Component.onCompleted: {
console.log("item1")
console.log(this === item1)
console.log(this === item2)
}
Item{
id: item2
Component.onCompleted: {
console.log("item2")
console.log(this === item1)
console.log(this === item2)
}
}
}
Conclusion:
qml: item1
qml: true
qml: false
qml: item2
qml: false
qml: true
source
share