QSvgWidget Class

The QSvgWidget class provides a widget that is used to display the contents of Scalable Vector Graphics (SVG) files. 更多...

头文件: #include <QSvgWidget>
qmake: QT += svg
开始支持版本: Qt 4.1
基类: QWidget

公有函数

QSvgWidget(QWidget *parent = Q_NULLPTR)
QSvgWidget(const QString &file, QWidget *parent = Q_NULLPTR)
~QSvgWidget()
QSvgRenderer *renderer() const

重新实现的公有函数

virtual QSize sizeHint() const override
  • 216 个公有函数继承自 QWidget

公有槽函数

void load(const QString &file)
void load(const QByteArray &contents)
  • 19 个公有槽函数继承自 QWidget

重新实现的受保护函数

virtual void paintEvent(QPaintEvent *event) override
  • 35 个受保护的函数继承自 QWidget

其他继承的成员

  • 59 个属性继承自 QWidget
  • 3 个信号继承自 QWidget
  • 5 个静态公有成员继承自 QWidget
  • 35 个受保护的函数继承自 QWidget
  • 1 个受保护的槽函数继承自 QWidget

详细描述

The QSvgWidget class provides a widget that is used to display the contents of Scalable Vector Graphics (SVG) files.

This class enables developers to display SVG drawings alongside standard widgets, and is used in much the same way as QLabel is used for displaying text and bitmap images.

Since QSvgWidget is a subclass of QWidget, SVG drawings are rendered using the properties of the display. More control can be exercised over the rendering process with the QSvgRenderer class, as this can be used to paint onto other paint devices, such as QImage and QGLWidget. The renderer used by the widget can be obtained with the renderer() function.

Each QSvgWidget can be constructed with the file name of a SVG file, or they can be constructed without a specific file to render and one can be supplied later. The load() functions provide two different ways to load an SVG file: they accept either the file name of an SVG file or a QByteArray containing the serialized XML representation of an SVG file.

By default, the widget provides a size hint to reflect the size of the drawing that it displays. If no data has been loaded, the widget provides the default QWidget size hint. Subclass this class and reimplement sizeHint() if you need to customize this behavior.

参见 QSvgRenderer, Qt SVG C++ Classes, and QPicture.

成员函数

QSvgWidget::QSvgWidget(QWidget *parent = Q_NULLPTR)

Constructs a new SVG display widget with the given parent.

QSvgWidget::QSvgWidget(const QString &file, QWidget *parent = Q_NULLPTR)

Constructs a new SVG display widget with the given parent and loads the contents of the specified file.

QSvgWidget::~QSvgWidget()

Destroys the widget.

[slot] void QSvgWidget::load(const QString &file)

Loads the contents of the specified SVG file and updates the widget.

[slot] void QSvgWidget::load(const QByteArray &contents)

Loads the specified SVG format contents and updates the widget.

[override virtual protected] void QSvgWidget::paintEvent(QPaintEvent *event)

重新实现 QWidget::paintEvent().

QSvgRenderer *QSvgWidget::renderer() const

Returns the renderer used to display the contents of the widget.

[override virtual] QSize QSvgWidget::sizeHint() const

重新实现 QWidget::sizeHint().