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

Transition does not correctly set value if target changes while transition runs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1: Critical P1: Critical
    • None
    • 6.2.2
    • Quick: Other
    • None

      Consider the following example. Pressing the button moves the green rectangle from left to right. Now resize the window while the animation is running. The rectangle moves to the old x target value and stays there, which leaves the application in an inconsistent state. Resizing the window again shows that x is correctly bound to "parent.width - rect.width" but it was never updated to the new value.

      This bug occurrs in Qt 6.2.2. It works correctly with Qt 5.15, which also runs the animation to the old target value, but then immediately moves the rectangle to the new value after the transition finished.

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          width: 640; height: 240
          visible: true
      
          Item {
              anchors.fill: parent
              state: "left"
      
              Rectangle {
                  id: rect
      
                  width: 100; height: 100
                  color: "green"
              }
              Button {
                  anchors {
                      bottom: parent.bottom
                      horizontalCenter: parent.horizontalCenter
                  }
                  text: "Change state"
                  onClicked: parent.state = "right"
              }
      
              states: [
                  State {
                      name: "left"
      
                      PropertyChanges { target: rect; x: 0 }
                  },
                  State {
                      name: "right"
      
                      PropertyChanges { target: rect; x: parent.width - rect.width }
                  }
              ]
              transitions: [
                  Transition {
                      NumberAnimation { property: "x"; duration: 3000 }
                  }
              ]
          }
      }
      

       

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

            hatemelkharashy Hatem ElKharashy
            enz Markus Enzenberger
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes