QIconEnginePlugin Class

QIconEnginePlugin 类为自定义QIconEngine 插件提供了一个抽象基础。更多

Header: #include <QIconEnginePlugin>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承: QObject

公共函数

QIconEnginePlugin(QObject *parent = nullptr)
virtual ~QIconEnginePlugin()
virtual QIconEngine *create(const QString &filename = QString()) = 0

详细说明

图标引擎插件是一个简单的插件接口,可轻松创建自定义图标引擎,并通过QIcon 将其动态加载到应用程序中。QIcon 使用文件或资源名称的后缀来确定要使用的图标引擎。

编写图标引擎插件的方法是子类化该基类,重新实现纯虚函数create() 并使用Q_PLUGIN_METADATA() 宏导出该类。

json 元数据应包含该插件支持的图标引擎键的列表。这些键与创建插件时使用的文件或资源名称的后缀相对应。键值不区分大小写。

{ "Keys": [ "myiconengine" ] }

另请参阅 如何创建 Qt 插件

成员函数文档

QIconEnginePlugin::QIconEnginePlugin(QObject *parent = nullptr)

用给定的parent 构建一个图标引擎插件。插件加载器会自动调用该插件。

[virtual noexcept] QIconEnginePlugin::~QIconEnginePlugin()

销毁图标引擎插件。

您不必明确调用此功能。当插件不再使用时,Qt 会自动将其销毁。

[pure virtual] QIconEngine *QIconEnginePlugin::create(const QString &filename = QString())

为图标创建QIconEngine 对象,并返回filename

© 2025 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.