En esta página

QGenericPlugin Class

La clase QGenericPlugin es una clase base abstracta para plugins. Más...

Cabecera: #include <QGenericPlugin>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Hereda: QObject

Funciones Públicas

QGenericPlugin(QObject *parent = nullptr)
virtual ~QGenericPlugin()
virtual QObject *create(const QString &key, const QString &specification) = 0

Descripción Detallada

Se puede crear un plugin de ratón subclasificando QGenericPlugin y reimplementando la función virtual pura create(). Exportando la clase derivada utilizando la macro Q_PLUGIN_METADATA(), La implementación por defecto de la clase QGenericPluginFactory detectará automáticamente el plugin y cargará el controlador en la aplicación servidor en tiempo de ejecución. Ver Cómo crear plugins Qt para más detalles.

El archivo de metadatos json debería contener una lista de claves soportadas por este plugin.

Véase también QGenericPluginFactory.

Documentación de las funciones miembro

[explicit] QGenericPlugin::QGenericPlugin(QObject *parent = nullptr)

Construye un plugin con la dirección parent.

Ten en cuenta que este constructor es invocado automáticamente por el código generado por moc que exporta el plugin, por lo que no es necesario llamarlo explícitamente.

[virtual noexcept] QGenericPlugin::~QGenericPlugin()

Destruye el plugin.

Tenga en cuenta que Qt destruye un plugin automáticamente cuando ya no se utiliza, por lo que no es necesario llamar al destructor explícitamente.

[pure virtual] QObject *QGenericPlugin::create(const QString &key, const QString &specification)

Implemente esta función para crear un controlador que coincida con el tipo especificado por los parámetros key y specification. Tenga en cuenta que las claves no distinguen entre mayúsculas y minúsculas.

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