Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved scalling an object smoothly over time

    QML and Qt Quick
    qml animation qtquick behavior
    3
    3
    268
    Loading More Posts
    • 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
      newbiSoso last edited by

      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.Hilk ODБOï 2 Replies Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @newbiSoso last edited by

        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

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

        1 Reply Last reply Reply Quote 3
        • ODБOï
          ODБOï @newbiSoso last edited by

          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 Reply Quote 2
          • First post
            Last post