QQmlExtensionPlugin Class
QQmlExtensionPlugin 类为具有自定义类型注册函数的自定义 QML 扩展插件提供了一个抽象基类。更多内容...
| 头文件: | #include <QQmlExtensionPlugin> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
| qmake: | QT += qml |
| 继承自: | QObject |
- 所有成员列表,包括继承的成员
- 已弃用的成员
- QQmlExtensionPlugin 属于插件类。
公共函数
(since 6.0) virtual void | unregisterTypes() |
重新实现的公共函数
| virtual void | initializeEngine(QQmlEngine *engine, const char *uri) override |
| virtual void | registerTypes(const char *uri) override = 0 |
详细说明
注意:如果您需要 手动编写插件(这种情况很少见),应始终使用QQmlEngineExtensionPlugin 。QQmlExtensionPlugin仅额外提供了registerTypes()和unregisterTypes()函数。您不应使用它们,而应使用QML_ELEMENT 及其相关函数声明您的类型,并让构建系统负责注册工作。
成员函数文档
[override virtual] void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
使用engine 从uri 初始化该扩展。例如,应用程序插件可能会将某些数据或对象作为引擎根上下文中的上下文属性,暴露给QML。
[override pure virtual] void QQmlExtensionPlugin::registerTypes(const char *uri)
将 QML 类型注册到指定的uri 中。子类应实现此方法,以便为扩展插件提供的所有类型调用qmlRegisterType()。
uri 是 QML 引擎根据扩展插件库的名称和路径生成的插件标识符。
[virtual, since 6.0] void QQmlExtensionPlugin::unregisterTypes()
重写此方法,以取消在registerTypes 中手动注册的类型的注册。
该函数于 Qt 6.0 中引入。
© 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.