QSvgWidgetclass 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
QLabelis used for displaying text and bitmap images.Since
QSvgWidget是子类化的QWidget, SVG drawings are rendered using the properties of the display. More control can be exercised over the rendering process with theQSvgRendererclass, as this can be used to paint onto other paint devices, such asQImageandQGLWidget. The renderer used by the widget can be obtained with therenderer()函数。每
QSvgWidgetcan 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. Theload()functions provide two different ways to load an SVG file: they accept either the file name of an SVG file or aQByteArraycontaining 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
QWidgetsize hint. Subclass this class and reimplementsizeHint()if you need to customize this behavior.另请参阅
QSvgRendererQt SVG C++ 类QPicture
QSvgWidget
(
[
parent=None
]
)
¶
QSvgWidget(file[, parent=None])
- param parent
QWidget- param file
unicode
Constructs a new SVG display widget with the given
parent
.
Constructs a new SVG display widget with the given
parent
and loads the contents of the specified
file
.
PySide2.QtSvg.QSvgWidget.
load
(
contents
)
¶
contents
–
QByteArray
PySide2.QtSvg.QSvgWidget.
load
(
file
)
¶
file – unicode
PySide2.QtSvg.QSvgWidget.
renderer
(
)
¶
Returns the renderer used to display the contents of the widget.