Home · All Classes · Modules |
The QSvgRenderer class is used to draw the contents of SVG files onto paint devices. More...
Inherits QObject.
The QSvgRenderer class is used to draw the contents of SVG files onto paint devices.
Using QSvgRenderer, Scalable Vector Graphics (SVG) can be rendered onto any QPaintDevice subclass, including QWidget, QImage, and QGLWidget.
QSvgRenderer provides an API that supports basic features of SVG rendering, such as loading and rendering of static drawings, and more interactive features like animation. Since the rendering is performed using QPainter, SVG drawings can be rendered on any subclass of QPaintDevice.
SVG drawings are either loaded when an QSvgRenderer is constructed, or loaded later using the load() functions. Data is either supplied directly as serialized XML, or indirectly using a file name. If a valid file has been loaded, either when the renderer is constructed or at some later time, isValid() returns true; otherwise it returns false. QSvgRenderer provides the render() slot to render the current document, or the current frame of an animated document, using a given painter.
The defaultSize() function provides information about the amount of space that is required to render the currently loaded SVG file. This is useful for paint devices, such as QWidget, that often need to supply a size hint to their parent layout. The default size of a drawing may differ from its visible area, found using the viewBox property.
Animated SVG drawings are supported, and can be controlled with a simple collection of functions and properties:
Finally, the QSvgRenderer class provides the repaintNeeded() signal which is emitted whenever the rendering of the document needs to be updated.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a new renderer with the given parent.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a new renderer with the given parent and loads the contents of the SVG file with the specified filename.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a new renderer with the given parent and loads the SVG data from the byte array specified by contents.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a new renderer with the given parent and loads the SVG data using the stream reader specified by contents.
This function was introduced in Qt 4.5.
Returns true if the current document contains animated elements; otherwise returns false.
See also framesPerSecond().
Returns bounding rectangle of the item with the given id. The transformation matrix of parent elements is not affecting the bounds of the element.
This function was introduced in Qt 4.2.
See also matrixForElement().
Returns the default size of the document contents.
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 function was introduced in Qt 4.2.
Returns true if there is a valid current document; otherwise returns false.
This method is also a Qt slot with the C++ signature bool load(const QString&).
Loads the SVG file specified by filename, returning true if the content was successfully parsed; otherwise returns false.
This method is also a Qt slot with the C++ signature bool load(const ::QByteArray&).
Loads the specified SVG format contents, returning true if the content was successfully parsed; otherwise returns false.
This method is also a Qt slot with the C++ signature bool load( ::QXmlStreamReader*).
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.
This function was introduced in Qt 4.5.
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().
This function was introduced in Qt 4.2.
See also boundsOnElement().
This method is also a Qt slot with the C++ signature void render( ::QPainter*).
Renders the current document, or the current frame of an animated document, using the given painter.
This method is also a Qt slot with the C++ signature void render( ::QPainter*,const ::QRectF&).
Renders the current document, or the current frame of an animated document, using the given painter on the specified bounds within the painter. If the bounding rectangle is not specified the SVG file is mapped to the whole paint device.
This method is also a Qt slot with the C++ signature void render( ::QPainter*,const QString&,const ::QRectF& = QRectF()).
Renders the given element with elementId using the given painter on the specified bounds. If the bounding rectangle is not specified the SVG element is mapped to the whole paint device.
Returns viewBoxF().toRect().
See also setViewBox() and viewBoxF().
This is the default overload of this signal.
This signal is emitted whenever the rendering of the document needs to be updated, usually for the purposes of animation.
PyQt 4.12.1 for X11 | Copyright © Riverbank Computing Ltd and The Qt Company 2015 | Qt 4.8.7 |