Deploy Qt ODBC application
My application uses Qt SQL this way
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+QDir::currentPath()+"/database.mdb");
and all the rest i开发者_如何学Cs done using QSqlRelationalTableModel
.
Now that deployment stage has come, the application works perfectly on the system where Qt (4.6.3) is installed , but on another clean system, there is this error while loading the database
"Driver not loaded"
I know this has something to do with copying the ODBC plugins... but simply copying qsqlodbc4.dll
to the app dir and
qApp->addLibraryPath(QDir::currentPath());
does not work!!
What is the solution to this?
Note: The app is not linked to the driver DLL, it uses Qt plugin mechanism.
Create this directory structure same as it was on pc having qt installation.
your.app.dir/plugins/your.plugin.folder (i.e your.plugin.folder is sqldrivers)
Copy your plugin under your.app.dir/plugins/your.plugin_folder
Then add this code
qApp->addLibraryPath( qApp->applicationDirPath() + "/plugins");
I hope this helps.
精彩评论