QSvgWidget 類

QSvgWidget 類提供用於顯示 SVG (可伸縮嚮量圖形) 文件內容的 Widget。 更多...

頭: #include <QSvgWidget>
qmake: QT += svg
Since: Qt 4.1
繼承: QWidget

該類在 Qt 4.1 引入。

公共函數

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

重實現公共函數

virtual QSize sizeHint () const override

公共槽

void load (const QByteArray & contents )
void load (const QString & file )

重實現保護函數

virtual void paintEvent (QPaintEvent * event ) override

詳細描述

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 () 函數。

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++ 類 ,和 QPicture .

成員函數文檔編製

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 .

QSvgWidget:: QSvgWidget ( QWidget * parent = nullptr)

Constructs a new SVG display widget with the given parent .

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

加載指定 SVG 格式 contents 和更新 Widget。

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

Loads the contents of the specified SVG file 和更新 Widget。

[虛擬] QSvgWidget:: ~QSvgWidget ()

銷毀 Widget。

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

重實現: QWidget::paintEvent (QPaintEvent *event).

QSvgRenderer *QSvgWidget:: renderer () const

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

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

重實現訪問函數為特性: QWidget::sizeHint .