DtkGui
5.5.23
DTK Gui module
include
util
dsvgrenderer.h
1
// SPDX-FileCopyrightText: 2022 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
14
QT_BEGIN_NAMESPACE
15
class
QPainter;
16
QT_END_NAMESPACE
17
18
#ifdef Q_OS_LINUX
19
DGUI_BEGIN_NAMESPACE
20
class
DSvgRendererPrivate;
21
class
DSvgRenderer
:
public
QObject
,
public
DTK_CORE_NAMESPACE::DObject
22
{
23
Q_PROPERTY(
QRectF
viewBox READ viewBoxF WRITE setViewBox)
24
public
:
25
explicit
DSvgRenderer
(
QObject
*parent = Q_NULLPTR);
26
DSvgRenderer
(
const
QString
&filename,
QObject
*parent = Q_NULLPTR);
27
DSvgRenderer
(
const
QByteArray
&contents,
QObject
*parent = Q_NULLPTR);
28
~DSvgRenderer
();
29
30
bool
isValid()
const
;
31
32
QSize
defaultSize()
const
;
33
34
QRect
viewBox()
const
;
35
QRectF
viewBoxF()
const
;
36
void
setViewBox(
const
QRect
&viewbox);
37
void
setViewBox(
const
QRectF
&viewbox);
38
39
QRectF
boundsOnElement(
const
QString
&
id
)
const
;
40
bool
elementExists(
const
QString
&
id
)
const
;
41
42
QImage toImage(
const
QSize
sz,
const
QString
&elementId =
QString
())
const
;
43
44
public
Q_SLOTS:
45
bool
load(
const
QString
&filename);
46
bool
load(
const
QByteArray
&contents);
47
void
render(QPainter *p);
48
void
render(QPainter *p,
const
QRectF
&bounds);
49
50
void
render(QPainter *p,
const
QString
&elementId,
51
const
QRectF
&bounds =
QRectF
());
52
53
private
:
54
D_DECLARE_PRIVATE(
DSvgRenderer
)
55
};
56
DGUI_END_NAMESPACE
57
#else
58
59
#include <QSvgRenderer>
60
DGUI_BEGIN_NAMESPACE
61
typedef
QSvgRenderer
DSvgRenderer
;
62
DGUI_END_NAMESPACE
63
64
#endif
65
66
#endif
// DSVGRENDERER_H
DSvgRenderer
提供了将SVG文件的内容绘制到绘制设备上的方法.
QByteArray
QObject
QRect
QRectF
QSize
QString
制作者
1.9.3