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

Anchor Animation doesn't preserve margin while animating.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.2.0
    • None
    • Windows 7 32-bit Mingw48

    Description

      During the following example, the margin value of 20 is not preserved during the anchor animation as the parent is changed.

      import QtQuick 2.0
      
      Item {
          id: root
      
          width: 1024
          height: 600
      
          Rectangle {
              id: redRect
              width: 200
              height: 200
              color: "red"
          }
      
          Rectangle {
              id: greenRect
      
              anchors.left: redRect.right
      
              width: 200
              height: 200
              color: "green"
          }
      
          Rectangle {
              id: yellowRect
              anchors.left: greenRect.right
              width: 200
              height: 200
              color: "yellow"
          }
      
          Rectangle {
              id: blueRect
      
              width: 50
              height: 50
              color: "blue"
      
              anchors.margins: 20
      
              state: "red"
      
              onStateChanged: console.log("StateChanged", state)
      
              states: [
                  State {
                      name: "green"
                      ParentChange {
                          target: blueRect
                          parent: greenRect
                          x: 0
                          y: 0
                      }
                      AnchorChanges {
                          target: blueRect
                          anchors.top: greenRect.top
                          anchors.left: greenRect.left
                      }
                  },
                  State {
                      name: "red"
                      ParentChange {
                          target: blueRect
                          parent: redRect
                          x: 0
                          y: 0
                      }
                      AnchorChanges {
                          target: blueRect
                          anchors {
                              top: redRect.top
                              left: redRect.left
                          }
                      }
                  },
                  State {
                      name: "yellow"
                      ParentChange {
                          target: blueRect
                          parent: yellowRect
                          x: 0
                          y: 0
                      }
                      AnchorChanges {
                          target: blueRect
                          anchors {
                              top: yellowRect.top
                              left: yellowRect.left
                          }
                      }
                  }
              ]
      
              MouseArea {
                  anchors.fill: parent
                  onClicked: if(blueRect.state == "red")
                                 blueRect.state = "green"
                              else if(blueRect.state == "green")
                                  blueRect.state = "yellow"
                              else
                                  blueRect.state = "red"
              }
      
              transitions: Transition {
                  ParallelAnimation {
                      ParentAnimation {
                          via: root
                          NumberAnimation {
                              properties: "x,y"
                              duration: 1000
                              easing.type: Easing.InOutQuad
                          }
                      }
                      AnchorAnimation {
                          duration: 1000
                          easing.type: Easing.InOutQuad
                      }
                  }
              }
          }
      }
      

      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
            miketrahearn Mike Trahearn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes