Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to scrub svg animation?
Qt 6.11 is out! See what's new in the release blog

How to scrub svg animation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 589 Views 2 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.
  • D Offline
    D Offline
    DDR0
    wrote on last edited by
    #1

    Hello. Using PyQt, I have created a little rotating triangle svg, the source for which was stolen from MDN. I create it like so:

    self.animWidget = QSvgWidget('assets/images/rotating-triangle.svg', self)
    self.animWidget.move(200,300)
    self.anim = self.animWidget.children()[0]
    self.animTimer = self.anim.children()[0]
    		
    self.uiAnimateTriangle.clicked.connect(self.animateTriangle)
    

    How do I scrub through it, ie, set animation speed to 0 and change the time in animation? Running the following gives very weird results:

    print('cf', self.anim.currentFrame()) #Prints "cf 95280", OK…
    self.anim.setCurrentFrame(10)
    print('nf', self.anim.currentFrame()) #Prints "nf 180600", wtf.
    

    In addition, setting self.anim.setFramesPerSecond(0) does seem to take, but it does not pause the animation. Calling self.animTimer.stop() seems to work, but I think it only is stopping the repaintNeeded signals from being emitted. When I emit them myself, the triangle is still animated.

    I'd like to have a little animated focus ring around some of my widgets, but I'm not sure how to do this if I can't control the animations.

    Thanks!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      QSvgRenderer does not give you the ability to start/stop the animation. You can only control the frame rate.

      BTW. what is the self.anim object? I don't see anything relating to it in documentation. I think you may be using some private APIs here.

      (Z(:^

      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