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. Can I do this Animation in Qt
Forum Updated to NodeBB v4.3 + New Features

Can I do this Animation in Qt

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 4 Posters 844 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    hello, can you give a tip or an example on how to make a counter with animation in the video using Qt quick and with the help of animations?

    https://youtu.be/dImb9e35QPg?t=449

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean a counter that increments and update the value shown at each step several times a second ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      ? 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean a counter that increments and update the value shown at each step several times a second ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @SGaist said in Can I do this Animation in Qt:

        Hi,

        Do you mean a counter that increments and update the value shown at each step several times a second ?

        yes i want something exactly like this

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can start from the Timer item example.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          ? 1 Reply Last reply
          1
          • SGaistS SGaist

            You can start from the Timer item example.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @SGaist So how can I apply the animation?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Define the animation because there was just a counter incrementing fast.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              ? 1 Reply Last reply
              0
              • SGaistS SGaist

                Define the animation because there was just a counter incrementing fast.

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by A Former User
                #7

                @SGaist

                Label {
                    id: moduleSize
                    property int currentValue: 0
                
                    PropertyAnimation {
                        id: propertyAnimation
                        target: moduleSize
                        properties: "text"
                        to: moduleSize.currentValue
                        duration: 10
                    }
                
                    Timer {
                        id: animationTimer
                        interval: 10
                        repeat: true
                        onTriggered: {
                            if(moduleSize.currentValue < count) {
                                moduleSize.currentValue++
                                propertyAnimation.start()
                            }
                        }
                    }
                    Component.onCompleted: {
                        animationTimer.start()
                    }
                }
                

                this worked well for me. I wasn't sure if I was using it correctly. If the count value taken as a parameter is a large number, the animation is completed in about 10 seconds.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  freedbrt
                  wrote on last edited by freedbrt
                  #8

                  I think the best way is to use behavior

                  import QtQuick 2.15
                  import QtQuick.Window 2.15
                  
                  Window {   
                      width: 640
                      height: 480
                      visible: true
                  
                      Timer { // Example Timer
                          interval: 16
                          running: true
                          repeat: true
                          onTriggered: {
                              moduleSize.currentValue += Math.random() * 100
                          }
                      }
                      
                      Text {
                          id: moduleSize
                  
                          anchors.centerIn: parent
                  
                          property int currentValue: 0
                  
                          Behavior on currentValue {
                              NumberAnimation { duration: 16 }
                          }
                  
                          text: currentValue
                      }
                  }
                  
                  
                  1 Reply Last reply
                  1
                  • haikuH Offline
                    haikuH Offline
                    haiku
                    wrote on last edited by
                    #9

                    @NullByte see here for a live example that increments the counter to random number every time you click the button.

                    And here's the code: https://gist.github.com/ollie-dawes/bbf5660804f2f3304d9e192849e12360

                    ? 1 Reply Last reply
                    0
                    • haikuH haiku

                      @NullByte see here for a live example that increments the counter to random number every time you click the button.

                      And here's the code: https://gist.github.com/ollie-dawes/bbf5660804f2f3304d9e192849e12360

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      @haiku Nice, thanks for sharing.

                      1 Reply Last reply
                      1

                      • Login

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