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

Anchors are not cleared after transition between states in some circumstances

    XMLWordPrintable

Details

    Description

      Given: two states; one state(name it AncState) has element anchoring changes and the other state(name it PosState) has absolute positioning changes of the same element.
      Action: If PosState is the first state then work will be done correctly all the way.
      If AncState is the first state then absolute positioning will be ignored until we explicitly set the anchors to undefined.

      "Code for reproducing the bug"
      import QtQuick 1.0
      
      Rectangle {
          id: container
          height: 100
          width: 100
          Text{
              id: text
              text: "some text"
          }
      
          MouseArea{
              anchors.fill: parent
              onClicked: container.state = "state1"
              onDoubleClicked: container.state = "state2"
          }
      
          states:[
              State{
                  name: "state1"
                  AnchorChanges{target: text; anchors.horizontalCenter: container.horizontalCenter}
                  PropertyChanges{target: text; y: 30}
              },
              State{
                  name: "state2"
                  PropertyChanges{target: text; x: 30; y: 30}
              }
          ]
      }
      

      Workarounds:

      First
      onClicked: container.state = "state2"
      onDoubleClicked: container.state = "state1"
      
      Second
      State{
      name: "state2"
      AnchorChanges{target: text; anchors.horizontalCenter: undefined}
      PropertyChanges{target: text; x: 30; y: 30}
      }
      

      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
            ixsci Eugene Shcherbina
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes