- class QSvgWidget¶
The
QSvgWidget
class provides a widget that is used to display the contents of Scalable Vector Graphics (SVG) files. More…Synopsis¶
Methods¶
def
__init__()
def
options()
def
renderer()
def
setOptions()
Slots¶
def
load()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
This class enables developers to display SVG drawings alongside standard widgets, and is used in much the same way as QLabel is used for displaying text and bitmap images.
Since
QSvgWidget
is a subclass of QWidget, SVG drawings are rendered using the properties of the display. More control can be exercised over the rendering process with theQSvgRenderer
class, as this can be used to paint onto other paint devices, such as QImage and QGLWidget. The renderer used by the widget can be obtained with therenderer()
function.Each
QSvgWidget
can be constructed with the file name of a SVG file, or they can be constructed without a specific file to render and one can be supplied later. Theload()
functions provide two different ways to load an SVG file: they accept either the file name of an SVG file or a QByteArray containing the serialized XML representation of an SVG file.By default, the widget provides a size hint to reflect the size of the drawing that it displays. If no data has been loaded, the widget provides the default QWidget size hint. Subclass this class and reimplement
sizeHint()
if you need to customize this behavior.See also
Constructs a new SVG display widget with the given
parent
.- __init__(file[, parent=None])
- Parameters:
file – str
parent –
QWidget
Constructs a new SVG display widget with the given
parent
and loads the contents of the specifiedfile
.- load(contents)¶
- Parameters:
contents –
QByteArray
Loads the specified SVG format
contents
and updates the widget.- load(file)
- Parameters:
file – str
Loads the contents of the specified SVG
file
and updates the widget.Returns the options of the widget’s renderer.
See also
- renderer()¶
- Return type:
Returns the renderer used to display the contents of the widget.
Sets the widget’s renderer options to
options
.This property holds a set of
Option
flags that can be used to enable or disable various features of the parsing and rendering of SVG files. It must be set before calling the load function to have any effect.By default, no flags are set.
See also