Deploy Qt ODBC Application

My application uses Qt SQL in this way

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+QDir::currentPath()+"/database.mdb");

and everything else is done with QSqlRelationalTableModel.

Now that the deployment phase has begun, the application works fine on the system where Qt (4.6.3) is installed, but on another clean system this error occurs when loading the database

"Driver not loaded"

I know this has to do with copying ODBC plugins ... but just copying qsqlodbc4.dllto the application directory and

qApp->addLibraryPath(QDir::currentPath());

does not work!!

What is the solution for this ?

Note. The application is not associated with the driver DLL, it uses the Qt plugin mechanism.

+3
source share
1 answer

Create this directory structure in the same way as on the qt installation computer.

your.app.dir/plugins/your.plugin.folder(, .plugin.folder - sqldrivers)

.pp.dir/plugins/your.plugin_folder

qApp->addLibraryPath( qApp->applicationDirPath() + "/plugins");

, .

+3

All Articles