Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsvgrenderer.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSVGRENDERER_H
5#define QSVGRENDERER_H
6
7#ifndef QT_NO_SVGRENDERER
8
9#include <QtCore/qobject.h>
10#include <QtCore/qsize.h>
11#include <QtCore/qrect.h>
12#include <QtCore/qxmlstream.h>
13#include <QtSvg/qtsvgglobal.h>
14
16
17
19class QPainter;
20class QByteArray;
21class QTransform;
22
23class Q_SVG_EXPORT QSvgRenderer : public QObject
24{
26
27 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
28 Q_PROPERTY(int framesPerSecond READ framesPerSecond WRITE setFramesPerSecond)
29 Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame)
30 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
31 Q_PROPERTY(QtSvg::Options options READ options WRITE setOptions)
32 Q_PROPERTY(bool animationEnabled READ isAnimationEnabled WRITE setAnimationEnabled)
33public:
34 QSvgRenderer(QObject *parent = nullptr);
35 QSvgRenderer(const QString &filename, QObject *parent = nullptr);
36 QSvgRenderer(const QByteArray &contents, QObject *parent = nullptr);
37 QSvgRenderer(QXmlStreamReader *contents, QObject *parent = nullptr);
38 ~QSvgRenderer();
39
40 bool isValid() const;
41
42 QSize defaultSize() const;
43
44 QRect viewBox() const;
45 QRectF viewBoxF() const;
46 void setViewBox(const QRect &viewbox);
47 void setViewBox(const QRectF &viewbox);
48
49 Qt::AspectRatioMode aspectRatioMode() const;
50 void setAspectRatioMode(Qt::AspectRatioMode mode);
51
52 QtSvg::Options options() const;
53 void setOptions(QtSvg::Options flags);
54
55 bool animated() const;
56 int framesPerSecond() const;
57 void setFramesPerSecond(int num);
58 int currentFrame() const;
59 void setCurrentFrame(int);
60 int animationDuration() const;//in seconds
61 bool isAnimationEnabled() const;
62 void setAnimationEnabled(bool enable);
63
64 QRectF boundsOnElement(const QString &id) const;
65 bool elementExists(const QString &id) const;
66 QTransform transformForElement(const QString &id) const;
67
68 static void setDefaultOptions(QtSvg::Options flags);
69
70public Q_SLOTS:
71 bool load(const QString &filename);
72 bool load(const QByteArray &contents);
73 bool load(QXmlStreamReader *contents);
74 void render(QPainter *p);
75 void render(QPainter *p, const QRectF &bounds);
76
77 void render(QPainter *p, const QString &elementId,
78 const QRectF &bounds=QRectF());
79
81 void repaintNeeded();
82
84 Q_DECLARE_PRIVATE(QSvgRenderer)
85};
86
88
89#endif // QT_NO_SVGRENDERER
90#endif // QSVGRENDERER_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtSvg
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
p1 load("image.bmp")
Combined button and popup list for selecting options.
Definition qcompare.h:63
GLenum mode
GLbitfield flags
GLboolean enable
GLfloat GLfloat p
[1]
GLuint num
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
myWidget render(this)