Nominate our 2022 Qt Champions!

QML NumberAnimation

  • Item 
        id: item
        width: parent.width
        height: parent.height
            id: rectangle
            color: "red"
            width: 7
            height: 30 
            target: rectangle;
            property: "x";
            from: 0;
            to: item.width;
            duration: 3500;
            loops: Animation.Infinite

    Inside NumberAnimation why is item.width zero?

    Edit: Formatting -- @Wieland

  • Qt Champions 2017

    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


    anchors.fill: parent

    to increase performance.

Log in to reply