IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

AnchorChanges QML Type

Specifies how to change the anchors of an item in a state.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

AnchorChanges QML Type

  • Import Statement: import QtQuick

  • Group: AnchorChanges is part of qtquick-states

Detailed Description

The AnchorChanges type is used to modify the anchors of an item in a State.

AnchorChanges cannot be used to modify the margins on an item. For this, use PropertyChanges instead.

In the following example we change the top and bottom anchors of an item using AnchorChanges, and the top and bottom anchor margins using PropertyChanges:

 
Sélectionnez
import QtQuick 2.0

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" }
}
Image non disponible

AnchorChanges can be animated using AnchorAnimation.

 
Sélectionnez
//animate our anchor changes
Transition {
    AnchorAnimation {}
}

Changes to anchor margins can be animated using NumberAnimation.

For more information on anchors see Anchor Layouts.

Property Documentation

 

anchors group

anchors.baseline : AnchorLine

anchors.bottom : AnchorLine

anchors.horizontalCenter : AnchorLine

anchors.left : AnchorLine

anchors.right : AnchorLine

anchors.top : AnchorLine

anchors.verticalCenter : AnchorLine

These properties change the respective anchors of the item.

To reset an anchor you can assign undefined:

 
Sélectionnez
AnchorChanges {
    target: myItem
    anchors.left: undefined          //remove myItem's left anchor
    anchors.right: otherItem.right
}

target : Item

This property holds the Item for which the anchor changes will be applied.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+