AnchorChanges QML Type
Specifica come modificare gli anchor di un elemento in uno stato. Altro...
| Import Statement: | import QtQuick |
Proprietà
- anchors
- anchors.baseline : AnchorLine
- anchors.bottom : AnchorLine
- anchors.horizontalCenter : AnchorLine
- anchors.left : AnchorLine
- anchors.right : AnchorLine
- anchors.top : AnchorLine
- anchors.verticalCenter : AnchorLine
- target : Item
Descrizione dettagliata
Il tipo AnchorChanges viene utilizzato per modificare gli ancoraggi di un elemento in un State.
AnchorChanges non può essere utilizzato per modificare i margini di un elemento. A tal fine, utilizzare invece PropertyChanges.
Nell'esempio seguente modifichiamo gli ancoraggi superiore e inferiore di un elemento utilizzando AnchorChanges, mentre modifichiamo i margini degli ancoraggi superiore e inferiore utilizzando 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" }
}
AnchorChanges può essere animato utilizzando AnchorAnimation.
//animate our anchor changes
Transition {
AnchorAnimation {}
}Le modifiche ai margini di ancoraggio possono essere animate utilizzando ` NumberAnimation`.
Per ulteriori informazioni sugli anchor, consultare la sezione " Layout degli anchor".
Documentazione sulle proprietà
anchors group
anchors.baseline : AnchorLine
anchors.bottom : AnchorLine
anchors.horizontalCenter : AnchorLine
anchors.left : AnchorLine
anchors.right : AnchorLine
anchors.top : AnchorLine
anchors.verticalCenter : AnchorLine
Queste proprietà modificano i rispettivi punti di ancoraggio dell'elemento.
Per reimpostare un'ancor undefined, è possibile assegnare un'ancor :
AnchorChanges {
target: myItem
anchors.left: undefined //remove myItem's left anchor
anchors.right: otherItem.right
}target : Item
Questa proprietà contiene l’ Item e a cui verranno applicate le modifiche all’ancora.
© 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.