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 Updated to NodeBB v4.3 + New Features

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 6 Sept 2019, 12:56 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 O 2 Replies Last reply 6 Sept 2019, 13:07
    0
    • N newbiSoso
      6 Sept 2019, 12:56

      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 Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 6 Sept 2019, 13:07 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
        6 Sept 2019, 12:56

        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?

        O Offline
        O Offline
        ODБOï
        wrote on 6 Sept 2019, 14:03 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

        3/3

        6 Sept 2019, 14:03

        • Login

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