QSqlDriverPlugin 类

The QSqlDriverPlugin class provides an abstract base for custom QSqlDriver 插件。 更多...

头: #include <QSqlDriverPlugin>
qmake: QT += sql
继承: QObject

公共函数

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

静态公共成员

const QMetaObject staticMetaObject

额外继承成员

详细描述

The QSqlDriverPlugin class provides an abstract base for custom QSqlDriver 插件。

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 插件 .