PySide6.QtSvg.QSvgGenerator¶
- class QSvgGenerator¶
The
QSvgGenerator
class provides a paint device that is used to create SVG drawings. More…Synopsis¶
Properties¶
descriptionᅟ
- The description of the generated SVG drawingfileNameᅟ
- The target filename for the generated SVG drawingoutputDeviceᅟ
- The output device for the generated SVG drawingresolutionᅟ
- The resolution of the generated outputsizeᅟ
- The size of the generated SVG drawingtitleᅟ
- The title of the generated SVG drawingviewBoxᅟ
- The viewBox of the generated SVG drawing
Methods¶
def
__init__()
def
description()
def
fileName()
def
outputDevice()
def
resolution()
def
setDescription()
def
setFileName()
def
setResolution()
def
setSize()
def
setTitle()
def
setViewBox()
def
size()
def
svgVersion()
def
title()
def
viewBox()
def
viewBoxF()
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¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
This paint device represents a Scalable Vector Graphics (SVG) drawing. Like QPrinter, it is designed as a write-only device that generates output in a specific format.
To write an SVG file, you first need to configure the output by setting the
fileName
oroutputDevice
properties. It is usually necessary to specify the size of the drawing by setting thesize
property, and in some cases where the drawing will be included in another, theviewBox
property also needs to be set.generator = QSvgGenerator() generator.setFileName(path) generator.setSize(QSize(200, 200)) generator.setViewBox(QRect(0, 0, 200, 200)) generator.setTitle(tr("SVG Generator Example Drawing")) generator.setDescription(tr("An SVG drawing created by the SVG Generator " "Example provided with Qt."))
Other meta-data can be specified by setting the
title
,description
andresolution
properties.As with other QPaintDevice subclasses, a QPainter object is used to paint onto an instance of this class:
painter = QPainter() painter.begin(generator) ... painter.end()
Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter::begin() and end() to explicitly begin and end painting on the device.
See also
- class SvgVersion¶
This enumeration describes the version of the SVG output of the generator.
Constant
Description
QSvgGenerator.SvgVersion.SvgTiny12
The generated document follows the SVG Tiny 1.2 specification.
QSvgGenerator.SvgVersion.Svg11
The generated document follows the SVG 1.1 specification.
Added in version 6.5.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property descriptionᅟ: str¶
This property holds the description of the generated SVG drawing.
See also
- Access functions:
- property fileNameᅟ: str¶
This property holds the target filename for the generated SVG drawing.
See also
- Access functions:
This property holds the output device for the generated SVG drawing.
If both output device and file name are specified, the output device will have precedence.
See also
- Access functions:
- property resolutionᅟ: int¶
This property holds the resolution of the generated output.
The resolution is specified in dots per inch, and is used to calculate the physical size of an SVG drawing.
- Access functions:
This property holds the size of the generated SVG drawing.
By default this property is set to
QSize(-1, -1)
, which indicates that the generator should not output the width and height attributes of the<svg>
element.Note
It is not possible to change this property while a QPainter is active on the generator.
See also
- property titleᅟ: str¶
This property holds the title of the generated SVG drawing.
See also
- Access functions:
This property holds the
viewBox
of the generated SVG drawing.By default this property is set to
QRect(0, 0, -1, -1)
, which indicates that the generator should not output theviewBox
attribute of the<svg>
element.Note
It is not possible to change this property while a QPainter is active on the generator.
See also
- Access functions:
- __init__()¶
Constructs a new generator using the SVG Tiny 1.2 profile.
- __init__(version)
- Parameters:
version –
SvgVersion
Constructs a new generator that uses the SVG version
version
.- description()¶
- Return type:
str
See also
Getter of property
descriptionᅟ
.- fileName()¶
- Return type:
str
See also
Getter of property
fileNameᅟ
.- outputDevice()¶
- Return type:
See also
Getter of property
outputDeviceᅟ
.- resolution()¶
- Return type:
int
See also
Getter of property
resolutionᅟ
.- setDescription(description)¶
- Parameters:
description – str
See also
Setter of property
descriptionᅟ
.- setFileName(fileName)¶
- Parameters:
fileName – str
See also
Setter of property
fileNameᅟ
.Setter of property
outputDeviceᅟ
.- setResolution(dpi)¶
- Parameters:
dpi – int
See also
Setter of property
resolutionᅟ
.Setter of property
sizeᅟ
.Setter of property
titleᅟ
.- setViewBox(viewBox)
- Parameters:
viewBox –
QRectF
Setter of property
viewBoxᅟ
.Getter of property
sizeᅟ
.- svgVersion()¶
- Return type:
Returns the version of the SVG document that this generator is producing.
- title()¶
- Return type:
str
See also
Getter of property
titleᅟ
.Returns
viewBoxF()
.toRect().See also
Getter of property
viewBoxᅟ
.