Hi all,
I have what I think is a very simple problem.. I want to find out an object's 'id' from javascript. Take the following example:
import QtQuick 2.0
Rectangle {
id: test
x: 10; y: 10
width: 122; height: 117
color: "red"
objectName: "testing"
MouseArea {
anchors.fill: parent
onClicked:
{
console.log("parent id: " + parent.id);
console.log("parent objectName: " + parent.objectName);
}
}
}
import QtQuick 2.0
Rectangle {
id: test
x: 10; y: 10
width: 122; height: 117
color: "red"
objectName: "testing"
MouseArea {
anchors.fill: parent
onClicked:
{
console.log("parent id: " + parent.id);
console.log("parent objectName: " + parent.objectName);
}
}
}
To copy to clipboard, switch view to plain text mode
The output from above is
parent id: undefined
parent objectName: testing
parent id: undefined
parent objectName: testing
To copy to clipboard, switch view to plain text mode
As a solution to my problem I can use objectName and this will work fine. The question is why can't I use id? I can not see any reason you shouldnt be able to do this, it seems perfectly valid to me.
Kind regards
Bookmarks