Skip to content

PythonQt.Qt.QSvgGenerator

QSvgGenerator

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

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 or outputDevice properties. It is usually necessary to specify the size of the drawing by setting the size property, and in some cases where the drawing will be included in another, the viewBox 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 and resolution properties.

As with other QPaintDevice subclasses, a QPainter 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 QPainter::begin() and end() 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.

Source: https://doc.qt.io/archives/qt-5.15/qsvggenerator.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
PaintDeviceMetric attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
PdmDepth attribute Any (shared captured text)
PdmDevicePixelRatio attribute Any (shared captured text)
PdmDevicePixelRatioScaled attribute Any (shared captured text)
PdmDpiX attribute Any (shared captured text)
PdmDpiY attribute Any (shared captured text)
PdmHeight attribute Any (shared captured text)
PdmHeightMM attribute Any (shared captured text)
PdmNumColors attribute Any (shared captured text)
PdmPhysicalDpiX attribute Any (shared captured text)
PdmPhysicalDpiY attribute Any (shared captured text)
PdmWidth attribute Any (shared captured text)
PdmWidthMM attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
colorCount function (self) -> int X.colorCount() -> int (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
depth function (self) -> int X.depth() -> int (shared captured text)
description function (self) -> str X.description() -> str (shared captured text)
devType function (self) -> int X.devType() -> int (shared captured text)
devicePixelRatio function (self) -> int X.devicePixelRatio() -> int (shared captured text)
devicePixelRatioF function (self) -> float X.devicePixelRatioF() -> float (shared captured text)
devicePixelRatioFScale function (self) -> float X.devicePixelRatioFScale() -> float (shared captured text)
fileName function (self) -> str X.fileName() -> str (shared captured text)
height function (self) -> int X.height() -> int (shared captured text)
heightMM function (self) -> int X.heightMM() -> int (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
initPainter function (self, painter: Any) -> Any (shared captured text)
logicalDpiX function (self) -> int X.logicalDpiX() -> int (shared captured text)
logicalDpiY function (self) -> int X.logicalDpiY() -> int (shared captured text)
metric function (self, metric: Any) -> int X.metric(metric) -> int (shared captured text)
outputDevice function (self) -> Any X.outputDevice() -> PythonQt.QtCore.QIODevice (shared captured text)
paintEngine function (self) -> Any X.paintEngine() -> PythonQt.QtGui.QPaintEngine (shared captured text)
paintingActive function (self) -> bool X.paintingActive() -> bool (shared captured text)
physicalDpiX function (self) -> int X.physicalDpiX() -> int (shared captured text)
physicalDpiY function (self) -> int X.physicalDpiY() -> int (shared captured text)
redirected function (self, offset: Any) -> Any X.redirected(offset) -> PythonQt.QtGui.QPaintDevice (shared captured text)
resolution function (self) -> int X.resolution() -> int (shared captured text)
setDescription function (self, description: str) -> None (shared captured text)
setFileName function (self, fileName: str) -> None (shared captured text)
setOutputDevice function (self, outputDevice: Any) -> None (shared captured text)
setResolution function (self, dpi: int) -> None (shared captured text)
setSize function (self, size: Any) -> None (shared captured text)
setTitle function (self, title: str) -> None (shared captured text)
setViewBox function (self, viewBox: Any) -> None (shared captured text)
sharedPainter function (self) -> Any X.sharedPainter() -> PythonQt.QtGui.QPainter (shared captured text)
size function (self) -> Any X.size() -> PythonQt.QtCore.QSize (shared captured text)
title function (self) -> str X.title() -> str (shared captured text)
viewBox function (self) -> Any X.viewBox() -> PythonQt.QtCore.QRect (shared captured text)
viewBoxF function (self) -> Any X.viewBoxF() -> PythonQt.QtCore.QRectF (shared captured text)
width function (self) -> int X.width() -> int (shared captured text)
widthMM function (self) -> int X.widthMM() -> int (shared captured text)