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

Can we bind a value back?



  • For example,

    @x: parent.width / 2@

    can make the item sit in the middle.

    If we assign a value to x, say: x = 20, it will always stay at 20, even parent.width changes.

    Is it possible to make it bind back to the parent's width again?


  • Moderators

    When you assign @x = 20@ then you are eoverridding the originalo binding @x: parent.width /2@ You can not have x at 20 and half the width of the parent at the same time.

    You might want to use anchors whenever possible. They are more efficient than bindings and allow for some really fancy layouts.



  • [quote author="Deqing" date="1296375893"]Is it possible to make it bind back to the parent's width again?[/quote]

    You can establish a new binding using PropertyChanges, or in the future (it isn't possible with QtQuick 1.0) from script as well (http://bugreports.qt.nokia.com/browse/QTBUG-14964).

    Regards,
    Michael



  • Thanks, using PropertyChanges works in my scenario


Log in to reply