December 17, 2010

xsacha xsacha
Lab Rat
517 posts

Behavior element has no ‘parent’ property

 

I am unable to refer to the parent item in animations as the Behavior element does not have a ‘parent’ property.

Example:

  1. Behavior on x { NumberAnimation {duration: parent.width } }

It is impossible to refer to the parent in this case without the parent having a known ID that you can use. This becomes more complicated in re-parented scenarios such as the one I was attempted to design.

Is there something I’m missing? How can I refer to variables in the parent item?

 Signature 

- Sacha

1 reply

December 17, 2010

mbrasser mbrasser
Ant Farmer
452 posts

You are correct — parent is a property of Item, the base class of all the visual items (but not Behavior, NumberAnimation, etc).

I’d recommend adding a suggestion in the bug tracker with some examples of things you’d like to achieve that are difficult without the parent property (like your example above).

Michael

 
  ‹‹ Scale will not reset if inside a State ’PropertyChanges’      Cannot use QML designer with custom components ››

You must log in to post a reply. Not a member yet? Register here!