QSvgWidget Class
The QSvgWidget class provides a widget that is used to display the contents of Scalable Vector Graphics (SVG) files. More...
Header: | #include <QSvgWidget> |
qmake: | QT += svg |
Since: | Qt 4.1 |
Inherits: | QWidget |
Public Functions
QSvgWidget(QWidget *parent = nullptr) | |
QSvgWidget(const QString &file, QWidget *parent = nullptr) | |
virtual | ~QSvgWidget() |
QSvgRenderer * | renderer() const |
Reimplemented Public Functions
virtual QSize | sizeHint() const override |
Public Slots
Static Public Members
const QMetaObject | staticMetaObject |
Reimplemented Protected Functions
virtual void | paintEvent(QPaintEvent *event) override |
Additional Inherited Members
- 59 properties inherited from QWidget
- 1 property inherited from QObject
- 3 signals inherited from QWidget
- 2 signals inherited from QObject
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected slot inherited from QWidget
Detailed Description
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.
See also QSvgRenderer, Qt SVG C++ Classes, and QPicture.
Member Function Documentation
QSvgWidget::QSvgWidget(QWidget *parent = nullptr)
Constructs a new SVG display widget with the given parent.
QSvgWidget::QSvgWidget(const QString &file, QWidget *parent = nullptr)
Constructs a new SVG display widget with the given parent and loads the contents of the specified file.
[virtual]
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)
Reimplemented from QWidget::paintEvent().
QSvgRenderer *QSvgWidget::renderer() const
Returns the renderer used to display the contents of the widget.
[override virtual]
QSize QSvgWidget::sizeHint() const
Reimplemented from QWidget::sizeHint().
© 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.