MuseScore
3.4
Music composition and notation
|
The SvgGenerator class provides a paint device that is used to create SVG drawings. . More...
#include <svggenerator.h>
Protected Member Functions | |
QPaintEngine * | paintEngine () const |
int | metric (QPaintDevice::PaintDeviceMetric metric) const |
Private Member Functions | |
QString | title () const |
the title of the generated SVG drawing More... | |
void | setTitle (const QString &title) |
QString | description () const |
the description of the generated SVG drawing More... | |
void | setDescription (const QString &description) |
QSize | size () const |
the size of the generated SVG drawing More... | |
void | setSize (const QSize &size) |
QRect | viewBox () const |
the viewBox of the generated SVG drawing More... | |
QRectF | viewBoxF () const |
void | setViewBox (const QRect &viewBox) |
void | setViewBox (const QRectF &viewBox) |
QString | fileName () const |
the target filename for the generated SVG drawing More... | |
void | setFileName (const QString &fileName) |
QIODevice * | outputDevice () const |
the output device for the generated SVG drawing More... | |
void | setOutputDevice (QIODevice *outputDevice) |
void | setResolution (int dpi) |
int | resolution () const |
the resolution of the generated output More... | |
void | setElement (const Ms::Element *e) |
Private Attributes | |
Q_DECLARE_PRIVATE(SvgGenerator) Q_PROPERTY(QSize size READ size WRITE setSize) Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox) Q_PROPERTY(QString title READ title WRITE setTitle) Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString fileName READ fileName WRITE setFileName) Q_PROPERTY(QIODevice *outputDevice READ outputDevice WRITE setOutputDevice) Q_PROPERTY(int resolution READ resolution WRITE setResolution) publi | ~SvgGenerator )() |
QScopedPointer< SvgGeneratorPrivate > | d_ptr |
The SvgGenerator class provides a paint device that is used to create SVG drawings. .
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.
|
private |
|
private |
|
protected |
|
private |
the output device for the generated SVG drawing
If both output device and file name are specified, the output device will have precedence.
|
protected |
Returns the paint engine used to render graphics to be converted to SVG format information.
|
private |
|
private |
|
private |
setElement() function Sets the _element variable in SvgPaintEngine. Called by saveSVG() in mscore/file.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
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.
|
private |
|
private |
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.
Returns viewBoxF().toRect().
|
private |
|
private |
|
private |
Destroys the generator.