开发者

Deploy Qt ODBC application

开发者 https://www.devze.com 2023-03-10 09:25 出处:网络
My application uses Qt SQL this way QSqlDatabase db = QSqlDatabase::addDatabase(\"QODBC\"); db.setDatabaseName(\"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"+QDir::currentPath()+\"/database.mdb\")

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消