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. scalling an object smoothly over time
Forum Update on Monday, May 27th 2025

scalling an object smoothly over time

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlanimationqtquickbehavior
3 Posts 3 Posters 548 Views
  • 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.
  • N Offline
    N Offline
    newbiSoso
    wrote on last edited by
    #1

    I have a rectangle where it's width increases to reach a certain value within 30 seconds, I wrote this which works fine but it's width increases in pulses ones every second:

    Timer{
        id: time
        interval: 1000; running: true; repeat: true
        onTriggered: 
             rect.width = ((outerRect.width * parseInt(time_val.text))/30) - (time_val.width/2)
    }
    

    what can I do to make it scale up smoothly?

    J.HilkJ ODБOïO 2 Replies Last reply
    0
    • N newbiSoso

      I have a rectangle where it's width increases to reach a certain value within 30 seconds, I wrote this which works fine but it's width increases in pulses ones every second:

      Timer{
          id: time
          interval: 1000; running: true; repeat: true
          onTriggered: 
               rect.width = ((outerRect.width * parseInt(time_val.text))/30) - (time_val.width/2)
      }
      

      what can I do to make it scale up smoothly?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @newbisoso

      inside your Rectangle write the following:

      Behavior on width {
              NumberAnimation { duration: 1000 }
          }
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • N newbiSoso

        I have a rectangle where it's width increases to reach a certain value within 30 seconds, I wrote this which works fine but it's width increases in pulses ones every second:

        Timer{
            id: time
            interval: 1000; running: true; repeat: true
            onTriggered: 
                 rect.width = ((outerRect.width * parseInt(time_val.text))/30) - (time_val.width/2)
        }
        

        what can I do to make it scale up smoothly?

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        hi
        @newbisoso said in scalling an object smoothly over time:

        pulses ones every second

        that is because you have an interval of 1000ms on the Timer, reducing the interval will make transition smoother
        but what @J-Hill suggested is probably more suited.

        1 Reply Last reply
        2

        • Login

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