Hello,
I’m learning QML, and I have a question about “Behavior”.
I wrote following code and the code doesn’t work as expected.
I expect that colors change slowly when I press and release a mouse button, but in fact colors change quickly.
When I comment out the first Behavior line and uncomment the second (use “Behavior on” syntax), the problem is solved.
What is wrong with the first Behavior line?
import QtQuick 2.0
Rectangle {
id: rect
width: 200
height: 200
MouseArea {
anchors.fill: rect
onPressed: rect.color = "black"
onReleased: rect.color = "white"
}
// This line seems to have no effect
Behavior { ColorAnimation { property: color; duration: 1000 } }
// This line works as expected
//Behavior on color { ColorAnimation { duration: 1000 } }
}
↧