QSvgGenerator¶
The
QSvgGenerator
class provides a paint device that is used to create SVG drawings. More…
Synopsis¶
Functions¶
def
description
()def
fileName
()def
outputDevice
()def
resolution
()def
setDescription
(description)def
setFileName
(fileName)def
setOutputDevice
(outputDevice)def
setResolution
(dpi)def
setSize
(size)def
setTitle
(title)def
setViewBox
(viewBox)def
setViewBox
(viewBox)def
size
()def
title
()def
viewBox
()def
viewBoxF
()
Detailed Description¶
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.QSvgGenerator generator; 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, aQPainter
object is used to paint onto an instance of this class:QPainter painter; 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
begin()
andend()
to explicitly begin and end painting on the device.The SVG Generator Example shows how the same painting commands can be used for painting a widget and writing an SVG file.
See also
QSvgRenderer
QSvgWidget
Qt SVG C++ Classes
- class PySide2.QtSvg.QSvgGenerator¶
Constructs a new generator.
- PySide2.QtSvg.QSvgGenerator.description()¶
- Return type:
str
This property holds the description of the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.fileName()¶
- Return type:
str
This property holds the target filename for the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.outputDevice()¶
- Return type:
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
- PySide2.QtSvg.QSvgGenerator.resolution()¶
- Return type:
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.
- PySide2.QtSvg.QSvgGenerator.setDescription(description)¶
- Parameters:
description – str
This property holds the description of the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.setFileName(fileName)¶
- Parameters:
fileName – str
This property holds the target filename for the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.setOutputDevice(outputDevice)¶
- Parameters:
outputDevice –
PySide2.QtCore.QIODevice
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
- PySide2.QtSvg.QSvgGenerator.setResolution(dpi)¶
- Parameters:
dpi – 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.
- PySide2.QtSvg.QSvgGenerator.setSize(size)¶
- Parameters:
size –
PySide2.QtCore.QSize
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
- PySide2.QtSvg.QSvgGenerator.setTitle(title)¶
- Parameters:
title – str
This property holds the title of the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.setViewBox(viewBox)¶
- Parameters:
viewBox –
PySide2.QtCore.QRect
- PySide2.QtSvg.QSvgGenerator.setViewBox(viewBox)
- Parameters:
viewBox –
PySide2.QtCore.QRectF
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
- PySide2.QtSvg.QSvgGenerator.size()¶
- Return type:
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
- PySide2.QtSvg.QSvgGenerator.title()¶
- Return type:
str
This property holds the title of the generated SVG drawing.
See also
- PySide2.QtSvg.QSvgGenerator.viewBox()¶
- Return type:
Returns
viewBoxF()
.toRect().See also
- PySide2.QtSvg.QSvgGenerator.viewBoxF()¶
- Return type:
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
© 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.