QSvgGenerator Class Reference

[ QtSvg module]

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

继承 QPaintDevice .

方法


详细描述

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

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 QPainter.begin () 和 end() to explicitly begin and end painting on the device.

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


方法文档编制

QSvgGenerator.__init__ ( self )

构造新的生成器。

QString QSvgGenerator.description ( self )

QString QSvgGenerator.fileName ( self )

int QSvgGenerator.metric ( self , QPaintDevice.PaintDeviceMetric   metric )

重实现自 QPaintDevice.metric ().

QIODevice QSvgGenerator.outputDevice ( self )

QPaintEngine QSvgGenerator.paintEngine ( self )

重实现自 QPaintDevice.paintEngine ().

Returns the paint engine used to render graphics to be converted to SVG format information.

int QSvgGenerator.resolution ( self )

QSvgGenerator.setDescription ( self , QString  description )

QSvgGenerator.setFileName ( self , QString  fileName )

QSvgGenerator.setOutputDevice ( self , QIODevice   outputDevice )

QSvgGenerator.setResolution ( self , int  resolution )

QSvgGenerator.setSize ( self , QSize   size )

QSvgGenerator.setTitle ( self , QString  title )

QSvgGenerator.setViewBox ( self , QRect   viewBox )

QSvgGenerator.setViewBox ( self , QRectF   viewBox )

QSize QSvgGenerator.size ( self )

QString QSvgGenerator.title ( self )

QRect QSvgGenerator.viewBox ( self )

返回 viewBoxF ().toRect().

该函数在 Qt 4.5 引入。

另请参阅 setViewBox () 和 viewBoxF ().

QRectF QSvgGenerator.viewBoxF ( self )