QSvgWidget 类提供用于显示 SVG (可伸缩向量图形) 文件内容的 Widget。 更多...
头: | #include <QSvgWidget> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
target_link_libraries(mytarget PRIVATE Qt6::SvgWidgets) |
qmake: | QT += svgwidgets |
继承: | QWidget |
QSvgWidget (QWidget * parent = nullptr) | |
QSvgWidget (const QString & file , QWidget * parent = nullptr) | |
virtual | ~QSvgWidget () |
(从 6.7 起)
QtSvg::Options
|
options () const |
QSvgRenderer * | renderer () const |
(从 6.7 起)
void
|
setOptions (QtSvg::Options options ) |
virtual QSize | sizeHint () const override |
void | load (const QString & file ) |
void | load (const QByteArray & contents ) |
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 .
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 .
[virtual noexcept]
QSvgWidget::
~QSvgWidget
()
销毁 Widget。
[slot]
void
QSvgWidget::
load
(const
QString
&
file
)
Loads the contents of the specified SVG file 和更新 Widget。
[slot]
void
QSvgWidget::
load
(const
QByteArray
&
contents
)
加载指定 SVG 格式 contents 和更新 Widget。
[since 6.7]
QtSvg::Options
QSvgWidget::
options
() const
Returns the options of the widget's renderer.
该函数在 Qt 6.7 引入。
另请参阅 setOptions .
[override virtual protected]
void
QSvgWidget::
paintEvent
(
QPaintEvent
*
event
)
重实现: QWidget::paintEvent (QPaintEvent *event).
Returns the renderer used to display the contents of the widget.
[since 6.7]
void
QSvgWidget::
setOptions
(
QtSvg::Options
options
)
Sets the widget's renderer options to options .
This property holds a set of QtSvg::Option flags that can be used to enable or disable various features of the parsing and rendering of SVG files. It must be set before calling the load function to have any effect.
By default, no flags are set.
该函数在 Qt 6.7 引入。
另请参阅 options .
[override virtual]
QSize
QSvgWidget::
sizeHint
() const
重实现访问函数为特性: QWidget::sizeHint .