Excuse me for my, possible, bad english I have a trouble with including qsqlite driver with my app. I have read a lot about including qsqlite4.dll with package on qtcentre or stackoverflow, but in my situation all of this solutions don't work. I downloaded QtSQK 4.7.3 with QtCreator and wrote a small app with Sqlite usage. I created the "plugins/sqldrivers" dir in my release output folder, found qsqlite4.dll (478720 bytes - in "/mingw/plugins/sqldrivers" folder), put it into the "plugins/sqldrivers" dir. Added the
a.addLibraryPath(a.applicationDirPath()+"/plugins");
a.addLibraryPath(a.applicationDirPath()+"/plugins");
To copy to clipboard, switch view to plain text mode
into main.cpp. After this i saw that
qDebug() << a.libraryPaths(); //where a is QApplication
qDebug() << a.libraryPaths(); //where a is QApplication
To copy to clipboard, switch view to plain text mode
will output "("app/release/plugins", "C:/QtSDK/Desktop/Qt/4.7.3/mingw/plugins", "app/release")", and through Resource Monitor in Win7 i see that qsqlite4.dll loaded when my app start and work fine with SQL. Then, i want to check, will it work on clear system without QT. If i rename the "C:/QtSDK/Desktop/Qt/4.7.3/mingw/plugins" to some like "plugins__", i see, that my app have only 2 paths - "..../release/plugins" and "..../release". In all that situations my QSqlDatabase found the QSQLITE driver -
db.drivers()
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.drivers()
To copy to clipboard, switch view to plain text mode
will output "QSQLITE". But, when i try to use qsqlite4.dll from my app bundle, i got a error from QSqlDatabase "Driver not loaded Driver not loaded". If i remove qsqlite4.dll from "myapp/plugins/sqldrivers" dir QSqlDatabase will not found them (db.drivers() return nothing), so i think i have a situation when driver DLL is founded by my app, but does not load. Why?
Trying not to use "app/plugins/sqldrivers/qsqlite4.dll" dir but use "app/sqldrivers/qsqlite4.dll" instead without adding a libraryPath does nothing, QSqlDatabase even does not found the driver and return nothing with db.drivers()..
It's like:
1.
app/plugins/sqldrivers/qsqlite4.dll
QtSDK/Desktop/Qt/4.7.3/mingw/plugins/sqldrivers/qsqlite4.dll - app use this file, all fine
2. app/plugins/sqldrivers/qsqlite4.dll - driver found, not loaded (with adding libraryPath "plugins");
3. app/sqldrivers/qsqlite.dll - driver not found, not loaded
In advance thank you all for the information..
Bookmarks