PDA

View Full Version : Cannot find id



sBoff
9th September 2013, 11:27
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);
}
}
}


The output from above is


parent id: undefined
parent objectName: testing


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

wysota
9th September 2013, 11:52
The id is not a property of the object. it's a reference to the object itself.