QQmlExtensionPlugin Class
QQmlExtensionPlugin 类为具有自定义类型注册功能的自定义 QML 扩展插件提供了一个抽象基础。更多
Header: | #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 和 friends 声明您的类型,并让构建系统负责注册。
成员函数文档
[override virtual]
void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
使用engine 从uri 初始化扩展。例如,应用程序插件可能会向 QML 公开一些数据或对象,作为引擎根上下文的上下文属性。
[override pure virtual]
void QQmlExtensionPlugin::registerTypes(const char *uri)
在给定的uri 中注册 QML 类型。子类应执行此功能,为扩展插件提供的所有类型调用qmlRegisterType() 。
uri 是 QML 引擎根据扩展插件库的名称和路径生成的插件标识符。
[virtual, since 6.0]
void QQmlExtensionPlugin::unregisterTypes()
重载此方法可取消在registerTypes 中手动注册的类型。
此函数在 Qt 6.0 中引入。
© 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.