<?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[QmL Random Scale Animation]]></title><description><![CDATA[<p dir="auto">i'm trying to create a way to make an image change randomly its scale. i need both the function that provides the random scale and the animation between the scales to be working. But it only does it the first time, any ideas why?</p>
<p dir="auto">if you know a easy way to do it i will appreciate that</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/import">@<bdi>import</bdi></a> QtQuick 2.2<br />
import QtQuick.Window 2.0<br />
import QtQuick.Controls 1.1</p>
<p dir="auto">Rectangle {<br />
id: container;<br />
width: 700<br />
height: 700</p>
<pre><code>function randomscales()
{
    var scalesArray = [1, 1,1, 1.1, 0.9, 1.2, 0.8,0.7]
    var randomNumber;
    var actualStateNumber
    do{
        randomNumber = Math.floor(Math.random()*scalesArray.length);
    }
    while (randomNumber == actualStateNumber);
    actualStateNumber = randomNumber;
    return scalesArray[randomNumber];
}

Timer{
    id: count1
    interval: 500
    running: true
    repeat: true
    onTriggered: {
        scaleAnimation.start()
        randomscales.start()
    }
}

Image {
    id: flor;
    source: "flor.png";
    x: 100
    y: 100
    scale: 1

    transform: Scale {
        id: scaleTransform
        property real scale: 1
        xScale: scale
        yScale: scale
        origin.x: 96
        origin.y: 104
    }

    SequentialAnimation {
        id: scaleAnimation
        loops: 1
        PropertyAnimation {
            target: scaleTransform
            properties: "scale"
            to: randomscales()
            duration: 500
        }
    }
}
</code></pre>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/51454/qml-random-scale-animation</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 08:19:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/51454.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Feb 2015 04:06:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QmL Random Scale Animation on Sat, 21 Feb 2015 07:43:08 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Starting the animation wont re-evaluate the binding and hence it wont update the <em>to</em> value. Instead you can<br />
@<br />
onTriggered: {<br />
<a href="http://propAnimation.to" target="_blank" rel="noopener noreferrer nofollow ugc">propAnimation.to</a> = randomscales() //propAnimation = id of PropertyAnimation<br />
scaleAnimation.start()<br />
}<br />
@</p>
<p dir="auto">Also randomscales.start() is wrong.</p>
]]></description><link>https://forum.qt.io/post/262407</link><guid isPermaLink="true">https://forum.qt.io/post/262407</guid><dc:creator><![CDATA[p3c0]]></dc:creator><pubDate>Sat, 21 Feb 2015 07:43:08 GMT</pubDate></item></channel></rss>