DtkGui
DTK Gui module
载入中...
搜索中...
未找到
dsvgrenderer.h
1// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSVGRENDERER_H
6#define DSVGRENDERER_H
7
8#include <dtkgui_global.h>
9#include <DObject>
10
11#include <QObject>
12#include <QRectF>
13
14QT_BEGIN_NAMESPACE
15class QPainter;
16QT_END_NAMESPACE
17
18DGUI_BEGIN_NAMESPACE
19class DSvgRendererPrivate;
20class DSvgRenderer : public QObject, public DTK_CORE_NAMESPACE::DObject
21{
22 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
23public:
24 explicit DSvgRenderer(QObject *parent = Q_NULLPTR);
25 DSvgRenderer(const QString &filename, QObject *parent = Q_NULLPTR);
26 DSvgRenderer(const QByteArray &contents, QObject *parent = Q_NULLPTR);
28
29 bool isValid() const;
30
31 QSize defaultSize() const;
32
33 QRect viewBox() const;
34 QRectF viewBoxF() const;
35 void setViewBox(const QRect &viewbox);
36 void setViewBox(const QRectF &viewbox);
37
38 QRectF boundsOnElement(const QString &id) const;
39 bool elementExists(const QString &id) const;
40
41 QImage toImage(const QSize sz, const QString &elementId = QString()) const;
42
43public Q_SLOTS:
44 bool load(const QString &filename);
45 bool load(const QByteArray &contents);
46 void render(QPainter *p);
47 void render(QPainter *p, const QRectF &bounds);
48
49 void render(QPainter *p, const QString &elementId,
50 const QRectF &bounds = QRectF());
51
52private:
53 D_DECLARE_PRIVATE(DSvgRenderer)
54};
55DGUI_END_NAMESPACE
56
57#endif // DSVGRENDERER_H
提供了将SVG文件的内容绘制到绘制设备上的方法.
Definition dsvgrenderer.h:21