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

ParentAnimation with via leaves item at wrong position if target moves

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.2
    • Quick: Other
    • None

    Description

      Run the following example. Pressing the button reparents and moves the yellow rectangle from the left blue rectangle to the right green rectangle. The final position is always the upper left corner of the parent. Now maximize the window while the animation is running. The yellow rectangle ends up at the wrong position.

      I don't care if the animation updates is target position while it is running or if it uses the old target position first and then jumps to the new position after it has finished. However, it must leave the application in a consistent state.

      The bug occurs only if a via property is used. (There is no reason in the example to use via, but in a a real-world application it might be necessary because of clipping or stacking order).

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      ApplicationWindow {
          width: 640; height: 240
          visible: true
      
          ColumnLayout {
              anchors.fill: parent
              state: "left"
      
              RowLayout {
                  Layout.fillHeight: true
      
                  Rectangle {
                      id: rect1
      
                      color: "blue"
                      Layout.fillHeight: true
                      Layout.fillWidth: true
                  }
                  Rectangle {
                      id: rect2
      
                      color: "green"
                      Layout.fillHeight: true
                      Layout.fillWidth: true
                  }
              }
              Button {
                  text: "Change parent"
                  Layout.alignment: Qt.AlignHCenter
                  onClicked: parent.state = (parent.state === "left" ? "right": "left")
              }
      
              states: [
                  State {
                      name: "left"
      
                      ParentChange {
                          target: rect3
                          parent: rect1
                          x: 0; y: 0
                      }
                  },
                  State {
                      name: "right"
      
                      ParentChange {
                          target: rect3
                          parent: rect2
                          x: 0; y: 0
                      }
                  }
              ]
              transitions: [
                  Transition {
                      ParentAnimation {
      
                          via: contentItem
      
                          NumberAnimation {
                              properties: "x,y"
                              duration: 3000
                          }
                      }
                  }
              ]
          }
          Rectangle {
              id: rect3
      
              width: 100
              height: 100
              color: "yellow"
          }
      }
      
      

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            enz Markus Enzenberger
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes