![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtSvg More...
#include <qsvggenerator.h>
Public Types | |
enum class | SvgVersion { SvgTiny12 , Svg11 } |
![]() | |
enum | PaintDeviceMetric { PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM , PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY , PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled } |
Public Member Functions | |
QSvgGenerator () | |
Constructs a new generator using the SVG Tiny 1.2 profile. | |
QSvgGenerator (SvgVersion version) | |
~QSvgGenerator () | |
Destroys the generator. | |
QString | title () const |
void | setTitle (const QString &title) |
QString | description () const |
void | setDescription (const QString &description) |
QSize | size () const |
void | setSize (const QSize &size) |
QRect | viewBox () const |
QRectF | viewBoxF () const |
void | setViewBox (const QRect &viewBox) |
void | setViewBox (const QRectF &viewBox) |
QString | fileName () const |
void | setFileName (const QString &fileName) |
QIODevice * | outputDevice () const |
void | setOutputDevice (QIODevice *outputDevice) |
void | setResolution (int dpi) |
int | resolution () const |
SvgVersion | svgVersion () const |
![]() | |
virtual | ~QPaintDevice () |
virtual int | devType () const |
bool | paintingActive () const |
virtual QPaintEngine * | paintEngine () const =0 |
int | width () const |
int | height () const |
int | widthMM () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
qreal | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | colorCount () const |
int | depth () const |
Protected Member Functions | |
QPaintEngine * | paintEngine () const override |
Returns the paint engine used to render graphics to be converted to SVG format information. | |
int | metric (QPaintDevice::PaintDeviceMetric metric) const override |
\reimp | |
![]() | |
QPaintDevice () noexcept | |
virtual int | metric (PaintDeviceMetric metric) const |
virtual void | initPainter (QPainter *painter) const |
virtual QPaintDevice * | redirected (QPoint *offset) const |
virtual QPainter * | sharedPainter () const |
Properties | |
QSize | size |
the size of the generated SVG drawing | |
QRectF | viewBox |
the viewBox of the generated SVG drawing | |
QString | title |
the title of the generated SVG drawing | |
QString | description |
the description of the generated SVG drawing | |
QString | fileName |
the target filename for the generated SVG drawing | |
QIODevice * | outputDevice |
the output device for the generated SVG drawing | |
int | resolution |
the resolution of the generated output | |
Additional Inherited Members | |
![]() | |
static qreal | devicePixelRatioFScale () |
![]() | |
ushort | painters |
\inmodule QtSvg
The QSvgGenerator class provides a paint device that is used to create SVG drawings. \reentrant
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 \l fileName or \l outputDevice properties. It is usually necessary to specify the size of the drawing by setting the \l size property, and in some cases where the drawing will be included in another, the \l 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:
\dots
Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter::begin() and \l{QPainter::}{end()} to explicitly begin and end painting on the device.
Definition at line 22 of file qsvggenerator.h.
|
strong |
This enumeration describes the version of the SVG output of the generator.
\value SvgTiny12 The generated document follows the SVG Tiny 1.2 specification. \value Svg11 The generated document follows the SVG 1.1 specification.
Enumerator | |
---|---|
SvgTiny12 | |
Svg11 |
Definition at line 35 of file qsvggenerator.h.
QSvgGenerator::QSvgGenerator | ( | ) |
Constructs a new generator using the SVG Tiny 1.2 profile.
Definition at line 580 of file qsvggenerator.cpp.
|
explicit |
Constructs a new generator that uses the SVG version version.
Definition at line 590 of file qsvggenerator.cpp.
References d.
QSvgGenerator::~QSvgGenerator | ( | ) |
QString QSvgGenerator::description | ( | ) | const |
Definition at line 636 of file qsvggenerator.cpp.
References d.
QString QSvgGenerator::fileName | ( | ) | const |
Definition at line 735 of file qsvggenerator.cpp.
References d.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QPaintDevice.
Definition at line 834 of file qsvggenerator.cpp.
References d, QPaintDevice::devicePixelRatioFScale(), metric(), QPaintDevice::PdmDepth, QPaintDevice::PdmDevicePixelRatio, QPaintDevice::PdmDevicePixelRatioScaled, QPaintDevice::PdmDpiX, QPaintDevice::PdmDpiY, QPaintDevice::PdmHeight, QPaintDevice::PdmHeightMM, QPaintDevice::PdmNumColors, QPaintDevice::PdmPhysicalDpiX, QPaintDevice::PdmPhysicalDpiY, QPaintDevice::PdmWidth, QPaintDevice::PdmWidthMM, qRound(), and qWarning.
Referenced by metric().
QIODevice * QSvgGenerator::outputDevice | ( | ) | const |
Definition at line 769 of file qsvggenerator.cpp.
References d.
|
overrideprotectedvirtual |
Returns the paint engine used to render graphics to be converted to SVG format information.
Implements QPaintDevice.
Definition at line 825 of file qsvggenerator.cpp.
References d.
int QSvgGenerator::resolution | ( | ) | const |
Definition at line 797 of file qsvggenerator.cpp.
References d.
Definition at line 643 of file qsvggenerator.cpp.
References d, and description.
Definition at line 775 of file qsvggenerator.cpp.
References d, outputDevice, and qWarning.
void QSvgGenerator::setResolution | ( | int | dpi | ) |
Definition at line 803 of file qsvggenerator.cpp.
References d.
Definition at line 670 of file qsvggenerator.cpp.
Definition at line 623 of file qsvggenerator.cpp.
Definition at line 723 of file qsvggenerator.cpp.
References setViewBox(), and viewBox.
Referenced by setViewBox().
Definition at line 713 of file qsvggenerator.cpp.
QSize QSvgGenerator::size | ( | ) | const |
Definition at line 664 of file qsvggenerator.cpp.
References d.
QSvgGenerator::SvgVersion QSvgGenerator::svgVersion | ( | ) | const |
Returns the version of the SVG document that this generator is producing.
Definition at line 815 of file qsvggenerator.cpp.
References d.
QString QSvgGenerator::title | ( | ) | const |
Definition at line 616 of file qsvggenerator.cpp.
References d.
QRect QSvgGenerator::viewBox | ( | ) | const |
Returns viewBoxF().toRect().
Definition at line 707 of file qsvggenerator.cpp.
References d.
QRectF QSvgGenerator::viewBoxF | ( | ) | const |
Definition at line 694 of file qsvggenerator.cpp.
References d.
|
readwrite |
the description of the generated SVG drawing
Definition at line 76 of file qsvggenerator.h.
Referenced by setDescription().
|
readwrite |
the target filename for the generated SVG drawing
Definition at line 76 of file qsvggenerator.h.
Referenced by setFileName().
|
readwrite |
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 76 of file qsvggenerator.h.
Referenced by setOutputDevice().
|
readwrite |
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 76 of file qsvggenerator.h.
|
readwrite |
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 76 of file qsvggenerator.h.
|
readwrite |
the title of the generated SVG drawing
Definition at line 76 of file qsvggenerator.h.
Referenced by setTitle().
|
readwrite |
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> element.
Definition at line 76 of file qsvggenerator.h.
Referenced by setViewBox(), and setViewBox().