本页内容

QIconEnginePlugin Class

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

头文件: #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())

根据给定的filename ,创建并返回该图标的QIconEngine 对象。

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