QGenericPlugin Class
QGenericPlugin 类是插件的抽象基类。更多
头文件: | #include <QGenericPlugin> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QObject |
- 所有成员(包括继承成员)的列表
- QGenericPlugin 属于插件类。
公共函数
QGenericPlugin(QObject *parent = nullptr) | |
virtual | ~QGenericPlugin() |
virtual QObject * | create(const QString &key, const QString &specification) = 0 |
详细说明
通过子类化 QGenericPlugin 并重新实现纯虚拟create() 函数,可创建鼠标插件。通过使用Q_PLUGIN_METADATA() 宏导出派生类,QGenericPluginFactory 类的默认实现将自动检测插件,并在运行时将驱动程序加载到服务器应用程序中。详情请参阅如何创建 Qt 插件。
json 元数据文件应包含该插件支持的键的列表。
另请参见 QGenericPluginFactory 。
成员函数文档
[explicit]
QGenericPlugin::QGenericPlugin(QObject *parent = nullptr)
用给定的parent 构建一个插件。
请注意,导出插件的 moc 生成代码会自动调用该构造函数,因此无需明确调用。
[virtual noexcept]
QGenericPlugin::~QGenericPlugin()
销毁插件。
请注意,当插件不再使用时,Qt 会自动将其销毁,因此无需明确调用销毁器。
[pure virtual]
QObject *QGenericPlugin::create(const QString &key, const QString &specification)
执行此函数可创建与给定的key 和specification 参数指定的类型相匹配的驱动程序。注意,键不区分大小写。
© 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.