Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML NumberAnimation
Qt 6.11 is out! See what's new in the release blog

QML NumberAnimation

Scheduled Pinned Locked Moved Solved QML and Qt Quick
numberanimation
3 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Taz742T Offline
    Taz742T Offline
    Taz742
    wrote on last edited by A Former User
    #1
    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

    Do what you want.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by dheerendra
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      5
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        As a side note, replace...

        width: parent.width
        height: parent.height
        

        with...

        anchors.fill: parent
        

        to increase performance.

        1 Reply Last reply
        4

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved