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

Reparenting doesn't work properly when combined with anchor animation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.0.1, 5.0.2
    • None
    • Windows 7; Qt 5.0.1/Qt 5.0.2 for Windows 32-bit VS 2010.

    Description

      When changing a parent and anchoring at the same time the behavior is incorrect. In the following code blueRect gets clipped against redRect, although it should not:

      import QtQuick 2.0
       
      Item {
              id: topItem
              width: 200; height: 200
       
              Rectangle {
                      id: redRect
                      width: 100; height: 100
                      clip: true
                      x: 20
                      y: 20
                      color: "red"
              }
       
              Rectangle {
                      id: blueRect
                      width: 50; height: 50
                      color: "blue"
                      anchors { top: redRect.top; left: redRect.right }
       
                      states: State {
                              name: "reparented"
                              ParentChange { target: blueRect; parent: redRect; }
                              AnchorChanges { target: blueRect; anchors.left: redRect.left; }
                      }
       
                      transitions: Transition {
                              ParentAnimation { via: topItem }
                              AnchorAnimation { duration: 1000 }
                      }
       
                      MouseArea {
                              anchors.fill: parent;
                              onClicked: blueRect.state = "reparented"
                     }
              }
      }
      

      When I try to apply parent change after the anchor animation, the blueRect jumps down when the animation is complete, which is also incorrect:

      Item {
          id: topItem
          width: 200; height: 200
       
          Rectangle {
              id: redRect
              clip: true
              width: 100; height: 100
              x: 20
              y: 20
              color: "red"
          }
       
          Rectangle {
              id: blueRect
              width: 50; height: 50
              color: "blue"
              anchors { top: redRect.top; left: redRect.right }
       
              states: State {
                  name: "reparented"
                  AnchorChanges   { target: blueRect; anchors.left: redRect.left; }
              }
       
              transitions: Transition {
                  SequentialAnimation{
                      AnchorAnimation { duration: 1000 }
                      ScriptAction{ script: blueRect.parent = redRect }
                  }
              }
       
              MouseArea {
                  anchors.fill: parent;
                  onClicked: blueRect.state = "reparented"
              }
          }
      }
      

      Attachments

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

        Activity

          People

            aalpert Alan Alpert
            maxus Maxim Makhinya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes