本页内容

QGenericPlugin Class

QGenericPlugin 类是插件的一个抽象基类。更多内容...

头文件: #include <QGenericPlugin>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承自: QObject

公共函数

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 参数所指定的类型相匹配的驱动程序。请注意,键不区分大小写。

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