QML NumberAnimation



  • 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 is item.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.


  • Moderators

    As a side note, replace...

    width: parent.width
    height: parent.height
    

    with...

    anchors.fill: parent
    

    to increase performance.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.