QML NumberAnimation
Solved
QML and Qt Quick
-
Item { id: item width: parent.width height: parent.height Rectangle { id: rectangle color: "red" width: 7 height: 30 } NumberAnimation { target: rectangle; property: "x"; from: 0; to: item.width; duration: 3500; easing.type: Easing.CosineCurve; loops: Animation.Infinite } }
Inside
NumberAnimation
why isitem.width
zero?Edit: Formatting -- @Wieland
-
For item you specifying the parent.width. What is parent here ? Looks like there is not parent for your Item object. Hence item.width is zero. Specify some width & height for your top level object(Item). It should fix by itself.
-
As a side note, replace...
width: parent.width height: parent.height
with...
anchors.fill: parent
to increase performance.