They actually turn on (red/blue) immediately. Only when the reversible is set
it will be the same.
--Kuifei
import QtQuick 1.0
Rectangle {
width: 150; height: 250
Rectangle {
id: stopLight
x: 25; y: 15; width: 100; height: 100
}
Rectangle {
id: goLight
x: 25; y: 135; width: 100; height: 100
}
states: [
State {
name: "stop"
PropertyChanges { target: stopLight; color: "red" }
PropertyChanges { target: goLight; color: "black" }
},
State {
name: "go"
PropertyChanges { target: stopLight; color: "black" }
PropertyChanges { target: goLight; color: "green" }
}
]
MouseArea {
anchors.fill: parent
onClicked: parent.state == "stop" ?
parent.state = "go" : parent.state = "stop"
}
// transitions: [
// Transition {
// from: "*"; to: "*"
// PropertyAnimation {
// target: stopLight
// properties: "color"; duration: 5000
// }
// PropertyAnimation {
// target: goLight
// properties: "color"; duration: 5000
// }
// } ]
transitions: [
Transition {
from: "stop"; to: "go"
reversible: true
PropertyAnimation {
target: stopLight
properties: "color"; duration: 5000
}
},
Transition {
from: "go"; to: "stop"
reversible: true
PropertyAnimation {
target: goLight
properties: "color"; duration: 5000
}
}
]
}
From: [email protected]
[mailto:[email protected]] On Behalf Of ext Owen
Zhao
Sent: 2011年4月26日 9:56
To: [email protected]
Subject: [Qt-qml] The two transitions have the same result. But I think it
shouldn't.
Hi all,
I am learning the Qt Essentials(QML Version) by myself. And something in
transitions is confusing me.
In the pdf I download from nokia website, it says.
transitions: [
Transition {
from: "stop"; to: "go"
PropertyAnimation {
target: stop_light
properties: "color"; duration: 1000
}
},
Transition {
from: "go"; to: "stop"
PropertyAnimation {
target: go_light
properties: "color"; duration: 1000
}
} ]
is the same as
transitions: [
Transition {
from: "*"; to: "*"
PropertyAnimation {
target: stop_light
properties: "color"; duration: 1000
}
PropertyAnimation {
target: go_light
properties: "color"; duration: 1000
}
} ]
And when I run the code in qmlviewer, they do do the same thing.(full code is
provided at the bottom of this email) However, I believe they shouldn't be the
same. As in the first code when transitioning from the "stop" to "go" state,
the target is only the "stop_light", and in the second code when transition
accurs, both the "stop_light" and "go_light" are targets.
Am I wrong or there is something I misunderstood?
The full qml file code here:
import QtQuick 1.0
Rectangle {
width: 150; height: 250
Rectangle {
id: stopLight
x: 25; y: 15; width: 100; height: 100
}
Rectangle {
id: goLight
x: 25; y: 135; width: 100; height: 100
}
states: [
State {
name: "stop"
PropertyChanges { target: stopLight; color: "red" }
PropertyChanges { target: goLight; color: "black" }
},
State {
name: "go"
PropertyChanges { target: stopLight; color: "black" }
PropertyChanges { target: goLight; color: "green" }
}
]
state: "stop"
MouseArea {
anchors.fill: parent
onClicked: parent.state == "stop" ?
parent.state = "go" : parent.state = "stop"
}
transitions: [
Transition {
from: "*"; to: "*"
PropertyAnimation {
target: stopLight
properties: "color"; duration: 1000
}
PropertyAnimation {
target: goLight
properties: "color"; duration: 1000
}
} ]
}
--
Owen Zhao
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml