transitions.qml Example File | Qt 4.8 (original) (raw)

declarative/animation/states/qml/states/transitions.qml

import QtQuick 1.0

Rectangle { id: page width: 640; height: 480 color: "#343434"

[Image](qml-image.html) {
    id: userIcon
    x: topLeftRect.x; y: topLeftRect.y
    source: "qt-logo.png"
}

[Rectangle](qml-rectangle.html) {
    id: topLeftRect

    anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
    width: 46; height: 54
    color: "Transparent"; border.color: "Gray"; radius: 6
    
    
    [MouseArea](qml-mousearea.html) { anchors.fill: parent; onClicked: page.state = '' }
}

[Rectangle](qml-rectangle.html) {
    id: middleRightRect

    anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
    width: 46; height: 54
    color: "Transparent"; border.color: "Gray"; radius: 6

    
    [MouseArea](qml-mousearea.html) { anchors.fill: parent; onClicked: page.state = 'middleRight' }
}

[Rectangle](qml-rectangle.html) {
    id: bottomLeftRect

    anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
    width: 46; height: 54
    color: "Transparent"; border.color: "Gray"; radius: 6

    
    [MouseArea](qml-mousearea.html) { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
}

states: [
    
    [State](qml-state.html) {
        name: "middleRight"
        [PropertyChanges](qml-propertychanges.html) { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
    },

    
    [State](qml-state.html) {
        name: "bottomLeft"
        [PropertyChanges](qml-propertychanges.html) { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y  }
    }
]


transitions: [
    
    
    [Transition](qml-transition.html) {
        from: "*"; to: "middleRight"
        [NumberAnimation](qml-numberanimation.html) { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 }
    },
    
    
    [Transition](qml-transition.html) {
        from: "*"; to: "bottomLeft"
        [NumberAnimation](qml-numberanimation.html) { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 }
    },

    
    [Transition](qml-transition.html) {
        [NumberAnimation](qml-numberanimation.html) { properties: "x,y"; duration: 200 }
    }
]

}

© 2016 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.