Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-140858

[REG: 6.8 -> 6.9] QML Conditional Binding does not restore original value

XMLWordPrintable

    • Linux/Wayland

      According to Binding QML Type the Binding Type should restore a property to its original binding as soon as the when condition is false.

      This does not to be the case at all and can be reproduced in the following example.

      I expect the left Rectangle to switch its color from blue to transparent once every second. But it only switches to blue once.

      import QtQuick
      
      Window {
          id: root
      
          property bool isRectBlue: false
      
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Timer {
              interval: 1000
              repeat: true
              running: true
              onTriggered: function () {
                  root.isRectBlue = !root.isRectBlue
              }
          }
      
          Rectangle {
              anchors {
                  top: parent.top
                  left: parent.left
                  right: parent.horizontalCenter
                  bottom: parent.bottom
              }
      
              Binding on color {
                  when: root.isRectBlue
                  value: "blue"
              }
          }
      
          Rectangle {
              anchors {
                  top: parent.top
                  left: parent.horizontalCenter
                  right: parent.right
                  bottom: parent.bottom
              }
      
              color: root.isRectBlue ? "blue" : "transparent"
          }
      }
      
      

      The full compiling example is appended.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtqmlteam Qt Qml Team User
            doschr Dominik Schütz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes