QSvgWidget Class Reference

[ QtSvg module]

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

继承 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 () 函数。

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.


方法文档编制

QSvgWidget.__init__ ( self , QWidget   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new SVG display widget with the given parent .

QSvgWidget.__init__ ( self , QString  file , QWidget   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

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

QSvgWidget.load ( self , QString  file )

This method is also a Qt slot with the C++ signature void load(const QString&) .

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

QSvgWidget.load ( self , QByteArray   contents )

This method is also a Qt slot with the C++ signature void load(const QByteArray&) .

加载指定 SVG 格式 contents and updates the 小部件。

QSvgWidget.paintEvent ( self , QPaintEvent   event )

重实现自 QWidget.paintEvent ().

QSvgRenderer QSvgWidget.renderer ( self )

Returns the renderer used to display the contents of the 小部件。

QSize QSvgWidget.sizeHint ( self )

重实现自 QWidget.sizeHint ().