AnchorChanges QML Type
Indique comment modifier les ancres d'un élément dans un état. Plus d'informations...
| Import Statement: | import QtQuick |
Propriétés
- anchors
- anchors.baseline : AnchorLine
- anchors.bottom : AnchorLine
- anchors.horizontalCenter : AnchorLine
- anchors.left : AnchorLine
- anchors.right : AnchorLine
- anchors.top : AnchorLine
- anchors.verticalCenter : AnchorLine
- target : Item
Description détaillée
Le type AnchorChanges est utilisé pour modifier les ancrages d'un élément dans un site State.
AnchorChanges ne peut pas être utilisé pour modifier les marges d'un élément. Pour cela, il faut utiliser PropertyChanges.
Dans l'exemple suivant, nous modifions les ancres supérieure et inférieure d'un élément à l'aide de AnchorChanges et les marges des ancres supérieure et inférieure à l'aide de 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" } }

Les AnchorChanges peuvent être animés à l'aide de AnchorAnimation.
//animate our anchor changes Transition { AnchorAnimation {} }
Les modifications des marges d'ancrage peuvent être animées à l'aide de NumberAnimation.
Pour plus d'informations sur les ancres, voir Anchor Layouts.
Documentation sur les propriétés
anchors group
anchors.baseline : AnchorLine
anchors.bottom : AnchorLine
anchors.horizontalCenter : AnchorLine
anchors.left : AnchorLine
anchors.right : AnchorLine
anchors.top : AnchorLine
anchors.verticalCenter : AnchorLine
Ces propriétés modifient les ancres respectives de l'élément.
Pour réinitialiser un ancrage, vous pouvez attribuer undefined:
AnchorChanges { target: myItem anchors.left: undefined //remove myItem's left anchor anchors.right: otherItem.right }
target : Item
Cette propriété contient l'adresse Item pour laquelle les changements d'ancrage seront appliqués.
© 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.