<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to stop() Color Animation?]]></title><description><![CDATA[<p dir="auto">Following my code snippet:</p>
<p dir="auto">import QtQuick 2.9<br />
import QtQuick.Window 2.3</p>
<p dir="auto">Window<br />
{<br />
id:root<br />
visible: true<br />
width: 500<br />
height: 300<br />
color:"red"</p>
<pre><code>//to stop
Rectangle
{
    id: r1
    height: 100
    width: 100
    color: "green"

    MouseArea
    {
        anchors.fill: parent
        onClicked:
        {
            t1.running=false
            t1.stop()
        }

    }
}

//to start
Rectangle
{
    id: r2
    height: 100
    width: 100
    color: "black"
    anchors.top: r1.bottom

    MouseArea
    {
        anchors.fill: parent
        onClicked:
        {
            t1.running=true
            t1.start()
        }

    }
}

ColorAnimation on color { id:a; to: "yellow"; duration: 1000; onStopped: b.start(); running: false }
ColorAnimation on color { id:b; to: "green"; duration: 1000; onStopped: a.start();running: false }


Timer
{
    id: t1
    running: false
    onTriggered:
        a.start()
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">I want to stop the animation but using stop(), i am unable to stop the animation?<br />
I want to show blink of two colors and when stop is pressed it should stop and when start is pressed it should start.<br />
Can anyone suggest any idea?</p>
]]></description><link>https://forum.qt.io/topic/98752/how-to-stop-color-animation</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Apr 2026 22:07:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/98752.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Jan 2019 10:45:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to stop() Color Animation? on Tue, 22 Jan 2019 08:37:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mranger90">@<bdi>mranger90</bdi></a> Thank u very much. Problem solved</p>
]]></description><link>https://forum.qt.io/post/506334</link><guid isPermaLink="true">https://forum.qt.io/post/506334</guid><dc:creator><![CDATA[JasmineSethi]]></dc:creator><pubDate>Tue, 22 Jan 2019 08:37:48 GMT</pubDate></item><item><title><![CDATA[Reply to How to stop() Color Animation? on Mon, 21 Jan 2019 13:21:40 GMT]]></title><description><![CDATA[<p dir="auto">The problem is in your animation.  Every time one stops, the other will start, and you are depending on the timer state, which is incorrect. You need to depend on some other state variable.<br />
Here is a modified version:</p>
<pre><code>import QtQuick 2.9
import QtQuick.Window 2.2

Window {
    id:root
    visible: true
    width: 500
    height: 300
    color:"red"
    property bool colorRun;
    colorRun: true

    //to stop
    Rectangle
    {
        id: r1
        height: 100
        width: 100
        color: "green"


        MouseArea
        {
            anchors.fill: parent
            onClicked:
            {
                console.log("Green area clicked");
                t1.running = false
                t1.stop()
                a.stop()
                b.stop()
                colorRun = false;
            }

        }
    }

    //to start
    Rectangle
    {
        id: r2
        height: 100
        width: 100
        color: "black"
        anchors.top: r1.bottom


        MouseArea
        {
            anchors.fill: parent
            onClicked:
            {
                t1.running = true
                t1.start()
            }

        }
    }

    ColorAnimation on color { id:a; to: "yellow"; duration: 1000; onStopped: colorRun ? b.start() : b.stop(); running: false }
    ColorAnimation on color { id:b; to: "green"; duration: 1000; onStopped: colorRun ? a.start() : a.stop(); running: false }


    Timer
    {
        id: t1
        running: false
        onTriggered: {
            console.log("Timer Trigger fired");
            a.start()
            colorRun = true
        }
    }
}

</code></pre>
]]></description><link>https://forum.qt.io/post/506135</link><guid isPermaLink="true">https://forum.qt.io/post/506135</guid><dc:creator><![CDATA[mranger90]]></dc:creator><pubDate>Mon, 21 Jan 2019 13:21:40 GMT</pubDate></item><item><title><![CDATA[Reply to How to stop() Color Animation? on Mon, 21 Jan 2019 13:26:06 GMT]]></title><description><![CDATA[<p dir="auto">When you run this what is happening ? Is the timer really starting ? You are specifying just one second time for Animation. Just blink of an eye, your animation is complete. Can you debug the app by placing console.log and see what is happening ? Logs will help you to see what happening everywhere. Your issue is actually starting from timer &amp; short animation interval.</p>
]]></description><link>https://forum.qt.io/post/506126</link><guid isPermaLink="true">https://forum.qt.io/post/506126</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Mon, 21 Jan 2019 13:26:06 GMT</pubDate></item></channel></rss>