Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can we bind a value back?
Forum Updated to NodeBB v4.3 + New Features

Can we bind a value back?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Deqing
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbrasser
        wrote on last edited by
        #3

        [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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Deqing
          wrote on last edited by
          #4

          Thanks, using PropertyChanges works in my scenario

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved