Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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:
    @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?



  • 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":bugreports.qt.nokia.com with some examples of things you'd like to achieve that are difficult without the parent property (like your example above).

    Michael


Log in to reply