QT Development (47)--database driver layer
the drive layer is for specific databases andSQLThe interface layer provides the underlying bridge, the main classincludeQt SQLModulein theQsqldriver,Qsqldrivercreator,Qsqldrivercreatorbase,Qsqldriverpluginand theQsqlresult.
First,
Qsqldriver
Qsqldriver is to visit the specific SQL the abstract base class of the database, which cannot be used directly. If you want to create a custom database driver, you can override The pure virtual and virtual functions of the Qsqldriver class as needed.
Custom Database Drivers
Qsqldatabase responsible for loading and managing the database driver plug-in. When a database is added, the corresponding database driver plug-in is loaded. the qsqldatabase relies on driver plug-ins to provide interfaces for Qsqldriver and qsqlresult .
Qsqldriver is to define the abstract base class for SQL database functionality.
Second,
Qsqldrivercreator
qsqldrivercreator is to provide <t> types of instantiated objects
[virtual] Qsqldriver *qsqldrivercreator::createobject () const
the Qsqldrivercreatorbase::createobject () override of function
Third,
Qsqldrivercreatorbase
Qsqldrivercreatorbase is a base class for SQL-driven factories.
[pure virtual] Qsqldriver *qsqldrivercreatorbase::createobject () const
Override this function to return a Qsqldriver instances of subclasses
Four,
Qsqldriverplugin
Qsqldriverplugin class provides a custom Qsqldriver the abstract base class for the plug-in.
The SQL database driver plugin is a simple plug-in interface that can be easily created by a custom SQL database driver plug-in that is dynamically loaded by QT.
Write The SQL plug-in can be implemented by deriving the qsqldriverplugin class, overriding the pure virtual function Create (), using the macro q_plugin_metadata () export class.
Pure virtual] Qsqldriver *qsqldriverplugin::create (const QString &key)
creates and returns a Qsqldriver object with a drive named key
Five,
Qsqlresult
Qsqlresult class provides access to the specific abstract interface for SQL database data.
Usually use qsqlresult qsqlquery provides a database-specific qsqlresult universal packaging implemented.
If you derive from Qsqldriver Implementing a custom SQL driver, you need to provide a custom implementation of all pure virtual functions and required virtual functions Qsqlresult sub-class.
[protected] qsqlresult::qsqlresult (const qsqldriver *db)
using Database Drivers db to build a Qsqlresult Object
This article from "Life is endless, struggle not only" blog, declined reprint!
QT Development (47)--Database driver layer