QSvgGenerator 類提供用於創建 SVG 繪製的描繪設備。 更多...
| 頭: | #include <QSvgGenerator> |
| qmake: | QT += svg |
| Since: | Qt 4.3 |
| 繼承: | QPaintDevice |
該類在 Qt 4.3 引入。
注意: 此類的所有函數 可重入 .
|
| QSvgGenerator () | |
| virtual | ~QSvgGenerator () |
| QString | description () const |
| QString | fileName () const |
| QIODevice * | outputDevice () const |
| int | resolution () const |
| void | setDescription (const QString & 描述 ) |
| void | setFileName (const QString & fileName ) |
| void | setOutputDevice (QIODevice * outputDevice ) |
| void | setResolution (int dpi ) |
| void | setSize (const QSize & size ) |
| void | setTitle (const QString & title ) |
| void | setViewBox (const QRect & viewBox ) |
| void | setViewBox (const QRectF & viewBox ) |
| QSize | size () const |
| QString | title () const |
| QRect | viewBox () const |
| QRectF | viewBoxF () const |
| virtual int | metric (QPaintDevice::PaintDeviceMetric metric ) const override |
| virtual QPaintEngine * | paintEngine () const override |
此繪圖設備錶示 SVG (可伸縮嚮量圖形) 繪製。像 QPrinter,它被設計為隻寫設備以按特定格式生成輸齣。
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 , 描述 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.
The SVG 生成器範例 shows how the same painting commands can be used for painting a widget and writing an SVG file.
另請參閱 QSvgRenderer , QSvgWidget ,和 Qt SVG C++ 類 .
此特性保持生成 SVG 繪製的描述
該特性在 Qt 4.5 引入。
訪問函數:
| QString | 描述 () const |
| void | setDescription (const QString & 描述 ) |
另請參閱 title .
This property holds the target filename for the generated SVG drawing
該特性在 Qt 4.5 引入。
訪問函數:
| QString | fileName () const |
| void | setFileName (const QString & fileName ) |
另請參閱 outputDevice .
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.
該特性在 Qt 4.5 引入。
訪問函數:
| QIODevice * | outputDevice () const |
| void | setOutputDevice (QIODevice * outputDevice ) |
另請參閱 fileName .
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.
該特性在 Qt 4.5 引入。
訪問函數:
| int | resolution () const |
| void | setResolution (int dpi ) |
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>
元素。
注意: It is not possible to change this property while a QPainter is active on the generator.
該特性在 Qt 4.5 引入。
訪問函數:
| QSize | size () const |
| void | setSize (const QSize & size ) |
另請參閱 viewBox and resolution .
This property holds the title of the generated SVG drawing
該特性在 Qt 4.5 引入。
訪問函數:
| QString | title () const |
| void | setTitle (const QString & title ) |
另請參閱 description .
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 the viewBox attribute of the
<svg>
元素。
注意: It is not possible to change this property while a QPainter is active on the generator.
該特性在 Qt 4.5 引入。
訪問函數:
| QRectF | viewBoxF () const |
| void | setViewBox (const QRect & viewBox ) |
| void | setViewBox (const QRectF & viewBox ) |
另請參閱 viewBox (), size ,和 resolution .
構造新的生成器。
[虛擬]
QSvgGenerator::
~QSvgGenerator
()
銷毀生成器。
[override virtual protected]
int
QSvgGenerator::
metric
(
QPaintDevice::PaintDeviceMetric
metric
) const
重實現: QPaintDevice::metric (QPaintDevice::PaintDeviceMetric metric) const.
[override virtual protected]
QPaintEngine
*QSvgGenerator::
paintEngine
() const
重實現: QPaintDevice::paintEngine () const.
Returns the paint engine used to render graphics to be converted to SVG format information.
返迴 viewBoxF ().toRect().
該函數在 Qt 4.5 引入。
另請參閱 setViewBox () 和 viewBoxF ().