Animated SVG drawings are supported, and can be controlled with a simple collection of functions and properties:
PySide2.QtSvg.QSvgRenderer(contents[, parent=None])
PySide2.QtSvg.QSvgRenderer(contents[, parent=None])
PySide2.QtSvg.QSvgRenderer(filename[, parent=None])
param parent
:
PySide2.QtCore.QObject
param contents
:
PySide2.QtCore.QXmlStreamReader
param filename
:
Constructs a new renderer with the given
parent
.
Constructs a new renderer with the given
parent
and loads the SVG data using the stream reader specified by
contents
.
Returns true if the current document contains animated elements; otherwise returns false.
See also
framesPerSecond()
Returns the number of frames in the animation, or 0 if the current document is not animated.
See also
animated()
framesPerSecond
This property holds how rendering adheres to the SVG view box aspect ratio.
The accepted modes are:
IgnoreAspectRatio
(the default): the aspect ratio is ignored and the rendering is stretched to the target bounds.
KeepAspectRatio
: rendering is centered and scaled as large as possible within the target bounds while preserving aspect ratio.
Returns bounding rectangle of the item with the given
id
. The transformation matrix of parent elements is not affecting the bounds of the element.
See also
transformForElement()
This property holds the current frame of the document’s animation, or 0 if the document is not animated.
See also
framesPerSecond
animated()
Returns true if the element with the given
id
exists in the currently parsed SVG file and is a renderable element.
Note: this method returns true only for elements that can be rendered. Which implies that elements that are considered part of the fill/stroke style properties, e.g. radialGradients even tough marked with “id” attributes will not be found by this method.
This property holds the number of frames per second to be shown.
The number of frames per second is 0 if the current document is not animated.
See also
animated()
Loads the specified SVG in
contents
, returning true if the content was successfully parsed; otherwise returns false.
The reader will be used from where it currently is positioned. If
contents
is
null
, behavior is undefined.
Use
transformForElement()
instead.
Returns the transformation matrix for the element with the given
id
. The matrix is a product of the transformation of the element’s parents. The transformation of the element itself is not included.
To find the bounding rectangle of the element in logical coordinates, you can apply the matrix on the rectangle returned from
boundsOnElement()
.
See also
boundsOnElement()
This property holds how rendering adheres to the SVG view box aspect ratio.
The accepted modes are:
IgnoreAspectRatio
(the default): the aspect ratio is ignored and the rendering is stretched to the target bounds.
KeepAspectRatio
: rendering is centered and scaled as large as possible within the target bounds while preserving aspect ratio.
This property holds the current frame of the document’s animation, or 0 if the document is not animated.
See also
framesPerSecond
animated()
This property holds the number of frames per second to be shown.
The number of frames per second is 0 if the current document is not animated.
See also
animated()
Returns the transformation matrix for the element with the given
id
. The matrix is a product of the transformation of the element’s parents. The transformation of the element itself is not included.
To find the bounding rectangle of the element in logical coordinates, you can apply the matrix on the rectangle returned from
boundsOnElement()
.
See also
boundsOnElement()
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the
GNU Free Documentation License version 1.3
as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.