Qt 4.8
|
The QSvgGenerator class provides a paint device that is used to create SVG drawings. More...
#include <qsvggenerator.h>
Public Functions | |
QString | description () const |
QString | fileName () const |
QIODevice * | outputDevice () const |
QSvgGenerator () | |
Constructs a new generator. More... | |
int | resolution () const |
void | setDescription (const QString &description) |
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 |
~QSvgGenerator () | |
Destroys the generator. More... | |
Public Functions inherited from QPaintDevice | |
int | colorCount () const |
int | depth () const |
virtual int | devType () const |
virtual HDC | getDC () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
QT_DEPRECATED int | numColors () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
virtual void | releaseDC (HDC hdc) const |
int | width () const |
int | widthMM () const |
virtual | ~QPaintDevice () |
Protected Functions | |
int | metric (QPaintDevice::PaintDeviceMetric metric) const |
Reimplemented Function More... | |
QPaintEngine * | paintEngine () const |
Returns the paint engine used to render graphics to be converted to SVG format information. More... | |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Properties | |
QScopedPointer< QSvgGeneratorPrivate > | d_ptr |
QString | description |
the description of the generated SVG drawing More... | |
QString | fileName |
the target filename for the generated SVG drawing More... | |
QIODevice * | outputDevice |
the output device for the generated SVG drawing More... | |
int | resolution |
the resolution of the generated output More... | |
QSize | size |
the size of the generated SVG drawing More... | |
QString | title |
the title of the generated SVG drawing More... | |
QRectF | viewBox |
the viewBox of the generated SVG drawing More... | |
Additional Inherited Members | |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY } |
Static Public Functions inherited from QPaintDevice | |
static QWSDisplay * | qwsDisplay () |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
Related Functions inherited from QPaintDevice | |
const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Returns the QX11Info structure for the pd paint device. More... | |
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.
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:
...
Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter::begin() and QPainter::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.
Definition at line 62 of file qsvggenerator.h.
QSvgGenerator::QSvgGenerator | ( | ) |
Constructs a new generator.
Definition at line 551 of file qsvggenerator.cpp.
QSvgGenerator::~QSvgGenerator | ( | ) |
Destroys the generator.
Definition at line 563 of file qsvggenerator.cpp.
QString QSvgGenerator::description | ( | ) | const |
Referenced by setTitle().
QString QSvgGenerator::fileName | ( | ) | const |
Referenced by setFileName(), and setViewBox().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QPaintDevice.
Definition at line 807 of file qsvggenerator.cpp.
QIODevice* QSvgGenerator::outputDevice | ( | ) | const |
Referenced by setFileName().
|
protectedvirtual |
Returns the paint engine used to render graphics to be converted to SVG format information.
Implements QPaintDevice.
Definition at line 798 of file qsvggenerator.cpp.
int QSvgGenerator::resolution | ( | ) | const |
Referenced by setOutputDevice().
void QSvgGenerator::setDescription | ( | const QString & | description | ) |
Definition at line 610 of file qsvggenerator.cpp.
void QSvgGenerator::setFileName | ( | const QString & | fileName | ) |
Definition at line 720 of file qsvggenerator.cpp.
void QSvgGenerator::setOutputDevice | ( | QIODevice * | outputDevice | ) |
Definition at line 757 of file qsvggenerator.cpp.
void QSvgGenerator::setResolution | ( | int | dpi | ) |
Definition at line 788 of file qsvggenerator.cpp.
void QSvgGenerator::setSize | ( | const QSize & | size | ) |
Definition at line 640 of file qsvggenerator.cpp.
void QSvgGenerator::setTitle | ( | const QString & | title | ) |
Definition at line 587 of file qsvggenerator.cpp.
void QSvgGenerator::setViewBox | ( | const QRect & | viewBox | ) |
Definition at line 699 of file qsvggenerator.cpp.
void QSvgGenerator::setViewBox | ( | const QRectF & | viewBox | ) |
Definition at line 689 of file qsvggenerator.cpp.
QSize QSvgGenerator::size | ( | ) | const |
Referenced by setDescription().
QString QSvgGenerator::title | ( | ) | const |
Referenced by ~QSvgGenerator().
QRect QSvgGenerator::viewBox | ( | ) | const |
Referenced by viewBoxF().
QRectF QSvgGenerator::viewBoxF | ( | ) | const |
Definition at line 667 of file qsvggenerator.cpp.
|
private |
Definition at line 104 of file qsvggenerator.h.
|
private |
the description of the generated SVG drawing
Definition at line 69 of file qsvggenerator.h.
|
private |
the target filename for the generated SVG drawing
Definition at line 70 of file qsvggenerator.h.
|
private |
the output device for the generated SVG drawing
If both output device and file name are specified, the output device will have precedence.
Definition at line 71 of file qsvggenerator.h.
|
private |
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.
Definition at line 72 of file qsvggenerator.h.
|
private |
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.
Definition at line 66 of file qsvggenerator.h.
|
private |
the title of the generated SVG drawing
Definition at line 68 of file qsvggenerator.h.
|
private |
the viewBox of the generated SVG drawing
Returns viewBoxF().
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> element.
toRect().
\sa viewBoxF()
Definition at line 67 of file qsvggenerator.h.