内容表

上一话题

QGraphicsSvgItem

下一话题

QSvgRenderer

QSvgGenerator

QSvgGenerator class provides a paint device that is used to create SVG drawings. 更多

Inheritance diagram of PySide2.QtSvg.QSvgGenerator

概要

函数

详细描述

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 特性。

As with other QPaintDevice 子类, 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 begin() and end() to explicitly begin and end painting on the device.

SVG 生成器范例 shows how the same painting commands can be used for painting a widget and writing an SVG file.

另请参阅

QSvgRenderer QSvgWidget Qt SVG C++ 类

class QSvgGenerator

构造新的生成器。

PySide2.QtSvg.QSvgGenerator. description ( )
返回类型

unicode

另请参阅

setDescription()

PySide2.QtSvg.QSvgGenerator. fileName ( )
返回类型

unicode

另请参阅

setFileName()

PySide2.QtSvg.QSvgGenerator. outputDevice ( )
返回类型

QIODevice

另请参阅

setOutputDevice()

PySide2.QtSvg.QSvgGenerator. resolution ( )
返回类型

int

另请参阅

setResolution()

PySide2.QtSvg.QSvgGenerator. setDescription ( description )
参数

description – unicode

另请参阅

description()

PySide2.QtSvg.QSvgGenerator. setFileName ( fileName )
参数

fileName – unicode

另请参阅

fileName()

PySide2.QtSvg.QSvgGenerator. setOutputDevice ( outputDevice )
参数

outputDevice QIODevice

另请参阅

outputDevice()

PySide2.QtSvg.QSvgGenerator. setResolution ( dpi )
参数

dpi int

另请参阅

resolution()

PySide2.QtSvg.QSvgGenerator. setSize ( size )
参数

size QSize

另请参阅

size()

PySide2.QtSvg.QSvgGenerator. setTitle ( title )
参数

title – unicode

另请参阅

title()

PySide2.QtSvg.QSvgGenerator. setViewBox ( viewBox )
参数

viewBox QRect

PySide2.QtSvg.QSvgGenerator. setViewBox ( viewBox )
参数

viewBox QRectF

PySide2.QtSvg.QSvgGenerator. size ( )
返回类型

QSize

另请参阅

setSize()

PySide2.QtSvg.QSvgGenerator. title ( )
返回类型

unicode

另请参阅

setTitle()

PySide2.QtSvg.QSvgGenerator. viewBox ( )
返回类型

QRect

返回 viewBoxF() .toRect().

PySide2.QtSvg.QSvgGenerator. viewBoxF ( )
返回类型

QRectF