I am trying to use the new QtCreator 2.0 to make animations.

The GUI is simple enough, I have created several states, but I cannot figure 
out how to animate between them. This trivial example defines a couple states 
which chance location, opacity and color. I would like to start from the 
initial state, then progress from state1 to state2 ... etc, after state3, 
return to the original.

I can't figure out how to kick off and chain the animations. Any help would 
be... well, helpful. (And appreciated)
Also, is there a way to set this in the GUI, for now I am hand-editing the file.


import Qt 4.6

Rectangle {
    id: rectangle1
    width: 200
    height: 200
    Text {
        id: text1
        x: 37
        y: 78
        text: "Hello World"
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter
        font.pointSize: 25
        font.family: "NiteClub"
        color: "red"
    }
    states: [
        State {
            name: "State1"

            PropertyChanges {
                target: text1
                x: 68
                y: 6
                anchors.verticalCenterOffset: -77
                anchors.horizontalCenterOffset: 31
                opacity: 0.33
            }
        },
        State {
            name: "State2"
            PropertyChanges {
                target: text1
                x: 68
                y: 161
                anchors.horizontalCenterOffset: 31
                anchors.verticalCenterOffset: 78
                opacity: 1
            }
        },
        State {
            name: "State3"
            PropertyChanges {
                target: text1
                x: 37
                y: 84
                color: "#0011ff"
                anchors.horizontalCenterOffset: 0
                anchors.verticalCenterOffset: 0
                opacity: 1
            }
        }
    ]
    transitions:
    [
         Transition {
            from: "*"
            to: "State1"
            reversible: true
            ParallelAnimation {
                NumberAnimation {
                    property: "opacity"
                    duration: 1000
                    target: text1
                }
                NumberAnimation {
                    duration: 1000
                    target: text1
                    properties: "x,y"
                }
            }
        }
    ]
}


      
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to