QSqlDriverPlugin 类

QSqlDriverPlugin 类提供抽象基为自定义 QSqlDriver 插件。 更多...

头: #include <QSqlDriverPlugin>
CMake: find_package(Qt6 COMPONENTS Sql REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
qmake: QT += sql
继承: QObject

公共函数

  QSqlDriverPlugin (QObject * parent = nullptr)
virtual ~QSqlDriverPlugin ()
virtual QSqlDriver * create (const QString & key ) = 0

详细描述

The SQL driver plugin is a simple plugin interface that makes it easy to create your own SQL driver plugins that can be loaded dynamically by Qt.

Writing a SQL plugin is achieved by subclassing this base class, reimplementing the pure virtual function create (),和导出类采用 Q_PLUGIN_METADATA () macro. See the SQL plugins that come with Qt for example implementations (in the plugins/src/sqldrivers subdirectory of the source distribution).

The json file containing the metadata for the plugin contains a list of keys indicating the supported sql drivers

{ "Keys": [ "mysqldriver" ] }
					

另请参阅 如何创建 Qt 插件 .

成员函数文档编制

QSqlDriverPlugin:: QSqlDriverPlugin ( QObject * parent = nullptr)

Constructs a SQL driver plugin and sets the parent to parent . This is invoked automatically by the moc generated code that exports the plugin.

[虚拟] QSqlDriverPlugin:: ~QSqlDriverPlugin ()

Destroys the SQL driver plugin.

从不需要明确调用这。Qt 自动销毁插件当不再使用时。

[pure virtual] QSqlDriver *QSqlDriverPlugin:: create (const QString & key )

创建并返回 QSqlDriver object for the driver called key . The driver key is usually the class name of the required driver. Keys are case sensitive.

另请参阅 如何创建 Qt 插件 .