You can't use setTimeout()
in QML, it's only in JS for browsers, in Qml you must think declarative :
import QtQuick 2.0
Canvas {
id: canvas;
width: 360;
height: 360;
contextType: "2d";
renderStrategy: Canvas.Threaded;
renderTarget: Canvas.Image;
antialiasing: true;
smooth: true;
onPaint: {
if (context) {
context.clearRect (0, 0, width, height);
context.beginPath ();
context.moveTo (width / 2, height / 2);
context.arc (width / 2,
height / 2,
50,
0,
angle * Math.PI / 180,
false);
context.closePath ();
context.fillStyle = "red";
context.fill ();
}
}
property real angle : 0;
Timer {
interval: 1000;
repeat: true;
running: true;
onTriggered: {
// update your angle property as you want
canvas.angle = (canvas.angle < 360 ? canvas.angle +6 : 0);
// repaint
canvas.requestPaint ();
}
}
}
I took the liberty to set the best settings for Canvas to allow you to have the best possible rendering !