Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5
6#ifndef QSVGRENDERER_H
7#define QSVGRENDERER_H
8
9#ifndef QT_NO_SVGRENDERER
10
11#include <QtCore/qobject.h>
12#include <QtCore/qsize.h>
13#include <QtCore/qrect.h>
14#include <QtCore/qxmlstream.h>
15#include <QtSvg/qtsvgglobal.h>
16
18
19
21class QPainter;
22class QByteArray;
23class QTransform;
24
25class Q_SVG_EXPORT QSvgRenderer : public QObject
26{
27 Q_OBJECT
28
29 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
30 Q_PROPERTY(int framesPerSecond READ framesPerSecond WRITE setFramesPerSecond)
31 Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame)
32 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
33 Q_PROPERTY(QtSvg::Options options READ options WRITE setOptions)
34 Q_PROPERTY(bool animationEnabled READ isAnimationEnabled WRITE setAnimationEnabled)
35public:
36 QSvgRenderer(QObject *parent = nullptr);
37 QSvgRenderer(const QString &filename, QObject *parent = nullptr);
38 QSvgRenderer(const QByteArray &contents, QObject *parent = nullptr);
39 QSvgRenderer(QXmlStreamReader *contents, QObject *parent = nullptr);
40 ~QSvgRenderer();
41
42 bool isValid() const;
43
44 QSize defaultSize() const;
45
46 QRect viewBox() const;
47 QRectF viewBoxF() const;
48 void setViewBox(const QRect &viewbox);
49 void setViewBox(const QRectF &viewbox);
50
51 Qt::AspectRatioMode aspectRatioMode() const;
52 void setAspectRatioMode(Qt::AspectRatioMode mode);
53
54 QtSvg::Options options() const;
55 void setOptions(QtSvg::Options flags);
56
57 bool animated() const;
58 int framesPerSecond() const;
59 void setFramesPerSecond(int num);
60 int currentFrame() const;
61 void setCurrentFrame(int);
62 int animationDuration() const;
63 bool isAnimationEnabled() const;
64 void setAnimationEnabled(bool enable);
65
66 QRectF boundsOnElement(const QString &id) const;
67 bool elementExists(const QString &id) const;
68 QTransform transformForElement(const QString &id) const;
69
70 static void setDefaultOptions(QtSvg::Options flags);
71
72public Q_SLOTS:
73 bool load(const QString &filename);
74 bool load(const QByteArray &contents);
75 bool load(QXmlStreamReader *contents);
76 void render(QPainter *p);
77 void render(QPainter *p, const QRectF &bounds);
78
79 void render(QPainter *p, const QString &elementId,
80 const QRectF &bounds=QRectF());
81
82Q_SIGNALS:
83 void repaintNeeded();
84
85private:
86 Q_DECLARE_PRIVATE(QSvgRenderer)
87};
88
89QT_END_NAMESPACE
90
91#endif // QT_NO_SVGRENDERER
92#endif // QSVGRENDERER_H
friend class QPainter
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
QString pmcKey(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) const
bool tryLoad(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
static int hashKey(QIcon::Mode mode, QIcon::State state)
static QAtomicInt lastSerialNum
QHash< int, QByteArray > svgBuffers
QMultiHash< int, QPixmap > addedPixmaps
QHash< int, QString > svgFiles
QIcon::Mode loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
QIconEngine * clone() const override
Reimplement this method to return a clone of this icon engine.
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the icon as a pixmap with the required size, mode, and state.
QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override
void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override
Called by QIcon::addFile().
QSvgIconEngine(const QSvgIconEngine &other)
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the actual size of the icon the engine provides for the requested size, mode and state.
void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override
Called by QIcon::addPixmap().
bool isNull() override
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
\inmodule QtSvg
Combined button and popup list for selecting options.
@ OtherFile
@ SvgFile
@ CompressedSvgFile
static QByteArray maybeUncompress(const QByteArray &ba)
static FileType fileType(const QFileInfo &fi)