Results 1 to 2 of 2

Thread: Animated Svg not Rendering properly

  1. #1
    Join Date
    Jun 2018
    Posts
    1
    Platforms
    Windows

    Question Animated Svg not Rendering properly

    Hello guys,
    I am trying to create a custom widget for Qt Designer. I am including an svg image with an animated transition.
    If I try opening the image with a browser, it shows with the correct animation. When I use QSvgRenderer , the widget is static..
    According to the documentation ( http://doc.qt.io/qt-5/qsvgrenderer.html ) QSvgRenderer should be able to display animated svgs.

    Here is my paint event definition:
    Qt Code:
    1. painter = QPainter()
    2. painter.begin(self)
    3. painter.setRenderHint(QPainter.Antialiasing)
    4. #---------------------------------------
    5. if self.__status_flag:
    6. self._color = self.__status_color
    7. else:
    8. self._color = "#19FFBA"
    9. data = QByteArray()
    10. data.append(self.setSVG3(self._angle, self._direction, self._color))
    11. #---------------------------------------
    12. renderer = QSvgRenderer(data)
    13. renderer.render(painter)
    14. painter.end()
    To copy to clipboard, switch view to plain text mode 

    And here is the image:
    Qt Code:
    1. def setSVG3(self, angle, direction, color):
    2. myDraw4 = (
    3. ' <?xml version="1.0" encoding="UTF-8"?>'
    4. '<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">'
    5. '<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->'
    6.  
    7. '<g>'
    8. ' <title>Layer 1</title>'
    9. '<circle id="svg_1" r="200" cy="240" cx="320" stroke-width="5" stroke="#000000" fill="#aaffff"/>'
    10. '<path id="svg_3" d="m395.561676,270.517456c-17.577972,-31.65799 -21.009674,-41.274231 -15.197479,-42.577225c11.350861,-2.54921 9.068848,-17.138077 -6.823669,-43.600067c-19.92926,-33.183914 -58.970734,-53.562576 -95.644684,-49.925613c-14.231903,1.41687 -30.324097,4.331177 -35.751831,6.478638c-5.441162,2.151489 -2.104431,-1.854935 7.408112,-8.906158c47.569244,-35.245369 106.323914,-32.788689 153.192871,6.405731c18.68869,15.629211 44.405182,61.29126 44.405182,78.851456c0,4.98056 4.23996,9.798859 9.42218,10.712173c8.471344,1.501907 7.330566,5.451584 -11.319641,39.264984c-11.410187,20.673431 -22.14624,39.081757 -23.857971,40.892517c-1.720062,1.810089 -13.342102,-15.108459 -25.833069,-37.596436l0,0zm-151.122101,-61.03447c17.58194,31.657806 21.013611,41.270065 15.203796,42.581177c-11.357391,2.545181 -9.075211,17.133957 6.816895,43.596085c19.933533,33.183807 58.970917,53.561218 95.643127,49.924103c14.233643,-1.412659 30.324951,-4.327301 35.762054,-6.478546c5.428558,-2.151398 2.096069,1.850952 -7.416626,8.901855c-47.569305,35.251099 -106.319733,32.794434 -153.197296,-6.401215c-18.685333,-15.62796 -44.400726,-61.2901 -44.400726,-78.85022c0,-4.980713 -4.235718,-9.798996 -9.413681,-10.716431c-8.480927,-1.497849 -7.344452,-5.443436 11.309738,-39.25676c11.407318,-20.677551 22.142426,-39.08194 23.862442,-40.8965c1.715561,-1.810379 13.342239,15.104507 25.830276,37.596451l0,0z" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#000000"/>'
    11. '<animateTransform attributeName="transform" type="rotate" from="0 320 240" to="360 320 240" dur="4s" repeatCount="indefinite" />'
    12. '</g>'
    13. '</svg>'
    14. )
    15. return myDraw4
    To copy to clipboard, switch view to plain text mode 
    I hope it is clear, let me know if you need more info, I tried including everything that seemed relevant.
    Thank you very much

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Animated Svg not Rendering properly

    You may have to call QSvgRenderer::setFramesPerSecond() with a non-zero value in order to get it started even though the transform specifies a 4s duration. The frame rate is needed in order to determine the rotation increment for each frame within the 4 second cycle.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Animated GIF Problem
    By MSUdom5 in forum Qt Programming
    Replies: 9
    Last Post: 25th January 2016, 07:29
  2. Replies: 8
    Last Post: 7th November 2012, 20:20
  3. Pb with animated gif on Mac os
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2008, 14:38
  4. Animated Cursor
    By kemp in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2007, 08:53
  5. animated gif's
    By :db:sStrong in forum Newbie
    Replies: 2
    Last Post: 31st May 2006, 16:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.