AnchorChanges QML Type
Especifica cómo cambiar las anclas de un elemento en un estado. Más...
| Import Statement: | import QtQuick |
Propiedades
- anchors
- anchors.baseline : AnchorLine
- anchors.bottom : AnchorLine
- anchors.horizontalCenter : AnchorLine
- anchors.left : AnchorLine
- anchors.right : AnchorLine
- anchors.top : AnchorLine
- anchors.verticalCenter : AnchorLine
- target : Item
Descripción detallada
El tipo AnchorChanges se utiliza para modificar los anclajes de un elemento en un State.
AnchorChanges no puede utilizarse para modificar los márgenes de un elemento. Para ello, utilice PropertyChanges.
En el siguiente ejemplo cambiamos los anclajes superior e inferior de un elemento utilizando AnchorChanges, y los márgenes de anclaje superior e inferior utilizando 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" } }

Los AnchorChanges se pueden animar utilizando AnchorAnimation.
//animate our anchor changes Transition { AnchorAnimation {} }
Los cambios en los márgenes de anclaje pueden animarse utilizando NumberAnimation.
Para más información sobre las anclas, consulte Anchor Layouts.
Documentación de propiedades
anchors group
anchors.baseline : AnchorLine
anchors.bottom : AnchorLine
anchors.horizontalCenter : AnchorLine
anchors.left : AnchorLine
anchors.right : AnchorLine
anchors.top : AnchorLine
anchors.verticalCenter : AnchorLine
Estas propiedades cambian las respectivas anclas del elemento.
Para restablecer un ancla puede asignar undefined:
AnchorChanges { target: myItem anchors.left: undefined //remove myItem's left anchor anchors.right: otherItem.right }
target : Item
Esta propiedad contiene la dirección Item a la que se aplicarán los cambios de anclaje.
© 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.