AnchorChanges QML Type
Especifica como alterar as âncoras de um item em um estado. Mais...
| Import Statement: | import QtQuick |
Propriedades
- anchors
- anchors.baseline : AnchorLine
- anchors.bottom : AnchorLine
- anchors.horizontalCenter : AnchorLine
- anchors.left : AnchorLine
- anchors.right : AnchorLine
- anchors.top : AnchorLine
- anchors.verticalCenter : AnchorLine
- target : Item
Descrição detalhada
O tipo AnchorChanges é usado para modificar as âncoras de um item em um State.
O AnchorChanges não pode ser usado para modificar as margens de um item. Para isso, use o PropertyChanges.
No exemplo a seguir, alteramos as âncoras superior e inferior de um item usando AnchorChanges e as margens das âncoras superior e inferior usando PropertyChanges:
import QtQuick
Rectangle {
id: window
width: 120; height: 120
color: "black"
Rectangle { id: myRect; width: 50; height: 50; color: "red" }
states: State {
name: "reanchored"
AnchorChanges {
target: myRect
anchors.top: window.top
anchors.bottom: window.bottom
}
PropertyChanges {
target: myRect
anchors.topMargin: 10
anchors.bottomMargin: 10
}
}
MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" }
}
O `AnchorChanges` pode ser animado usando ` AnchorAnimation`.
//animate our anchor changes
Transition {
AnchorAnimation {}
}Alterações nas margens das âncoras podem ser animadas usando ` NumberAnimation`.
Para obter mais informações sobre âncoras, consulte Layouts de âncoras.
Documentação de propriedades
anchors group
anchors.baseline : AnchorLine
anchors.bottom : AnchorLine
anchors.horizontalCenter : AnchorLine
anchors.left : AnchorLine
anchors.right : AnchorLine
anchors.top : AnchorLine
anchors.verticalCenter : AnchorLine
Essas propriedades alteram as respectivas âncoras do item.
Para redefinir uma âncor undefined, você pode atribuir um valor a :
AnchorChanges {
target: myItem
anchors.left: undefined //remove myItem's left anchor
anchors.right: otherItem.right
}target : Item
Essa propriedade contém o objeto ` Item ` ao qual as alterações de âncora serão aplicadas.
© 2026 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 the GNU 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.