
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheAnchorChanges element allows you to change the anchors of an item in a state.More...
TheAnchorChanges element is used to modify the anchors of an item in aState.
AnchorChanges cannot be used to modify the margins on an item. For this, usePropertyChanges intead.
In the following example we change the top and bottom anchors of an item usingAnchorChanges, and the top and bottom anchor margins usingPropertyChanges:
import QtQuick 1.0Rectangle {id:windowwidth:120;height:120color:"black"Rectangle {id:myRect;width:50;height:50;color:"red" }states:State {name:"reanchored"AnchorChanges {target:myRectanchors.top:window.topanchors.bottom:window.bottom }PropertyChanges {target:myRectanchors.topMargin:10anchors.bottomMargin:10 } }MouseArea {anchors.fill:parent;onClicked:window.state="reanchored" }}

AnchorChanges can be animated usingAnchorAnimation.
//animate our anchor changesTransition {AnchorAnimation {}}
Margin animations can be animated usingNumberAnimation.
For more information on anchors seeAnchor Layouts.
These properties change the respective anchors of the item.
To reset an anchor you can assignundefined:
AnchorChanges {target:myItemanchors.left:undefined//remove myItem's left anchoranchors.right:otherItem.right}
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.