Oracle is often used in the work, but by default Qt is only SQLite and ODBC driver, the network has the corresponding driver installation introduction, its own experiment is feasible:
QT Environment: QT 5.0.2/mingw4.7.2/win7 32bit
Open qt Command Prompt and execute the following commands to compile the Oracle driver:
Set include=%include%; C:\oracle\product\10.2.0\db_1\OCI\include; C:\Qt\Qt5.0.2\Tools\MinGW\include
Set lib=%lib%; C:\oracle\product\10.2.0\db_1\OCI\lib\MSVC
CD C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\oci
Qmake Oci.pro
Mingw32-make
Where C:\oracle\product\10.2.0\db_1\OCI\include is the directory where Oracle OCI drives source code, D:/qt/mingw/include is the location of the compilation environment.
After executing the above statement, you will generate LIBQSQLOCI.A, LIBQSQLOCID.A, Qsqloci.dll, qsqlocid.dll four files, copy them to C:\Qt\Qt5.0.2\5.0.2\mingw47_32\ In the Plugins\sqldrivers directory.
Test in the program:
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QDebug>
#include <QStringList>
int main (int argc, char *argv[])
{
Qcoreapplication A (argc, argv);
Qdebug () << "Available drivers:";
Qstringlist drivers = qsqldatabase::d rivers ();
foreach (QString driver, drivers)
Qdebug () << "/t" << driver;
return A.exec ();
}
You can see the list of drivers that are now available: