How i can check what parent is existing?
-
I try:
@Rectangle {
id:wo
width: parent.width*0.6
}@And I'm getting the error:
TypeError: Cannot read property of nullAnd therefore I want something like:
@if(parent.exist) return parent.width;
else return Screen.width;@How can I do this?
-
@
Rectangle {
id:wo
width: (parent === null)? Screen.width : parent.width
}
@ -
I try it and it's not working.
If we use:
@(parent === null)? parent.height : Screen.height@
result is always true
If we use:
@width: (parent === null)? Screen.width : parent.width@
result is always false -
What about
@
parent === undefined?
@
or
@
parent.width === undefined
@ -
the same behaviour ((
-
OK. Uncle Google told me this: "link":http://stackoverflow.com/questions/11040472/check-if-object-property-exists-using-a-variable.
-
yes, it is. parent is object type which is have the "width"' property, but the parent himself is wasn't created