[Interest] QtQuick ColorAnimation not working as expected
Preet
prismatic.project at gmail.com
Sun Mar 23 22:33:05 CET 2014
Hiya,
I have a simple use case where I want to animate the color of an item
in a loop back and forth. I can do this fine using PropertyAnimation,
but it doesn't work when I use ColorAnimation. I've attached a very
simple example showing what I mean. Does anyone know what the issue is
here? Using ColorAnimation instead of PropetyAnimation results in
nothing happening -- no error message or anything like that, whereas
PropertyAnimation cycles the colors as expected.
Regards,
Preet
// ============================================================== //
import QtQuick 2.1
Rectangle
{
id: root;
width: 800; height: 480;
color: "#333333";
Rectangle {
id: rect;
width: 200; height: 200;
anchors.centerIn: parent;
color: "#71C837";
}
SequentialAnimation {
running: true;
loops: Animation.Infinite;
PropertyAnimation {
target: rect; property: "color";
from: "#71C837"; to: "#5FD3BC";
duration: 500;
}
PropertyAnimation {
target: rect; property: "color";
from: "#5FD3BC"; to: "#71C837";
duration: 500;
}
}
// Why doesn't ColorAnimation work like
// the above PropertyAnimation?
/*
SequentialAnimation {
running: true;
loops: Animation.Infinite;
ColorAnimation {
target: rect;
from: "#71C837";
to: "#5FD3BC";
duration: 500;
}
ColorAnimation {
target: rect;
from: "#5FD3BC";
to: "#71C837";
duration: 500;
}
}
*/
}
More information about the Interest
mailing list