First, add few checks to your implementation (if you do not have those already)
// Ensure QSQLITE driver is supported
if (!QSqlDatabase::drivers().
contains("QSQLITE")) { // Print something ... }
// Ensure QSQLITE driver is supported
if (!QSqlDatabase::drivers().contains("QSQLITE")) { // Print something ... }
To copy to clipboard, switch view to plain text mode
And then you could try next way to access DB file:
mDB.setDatabaseName("databases/juicemania.db");
mDB.setDatabaseName("databases/juicemania.db");
To copy to clipboard, switch view to plain text mode
Because the default folder is your private folder there is no need to access your files via applicationDirPath -method. And last thing is that after failing to open DB, print information about the error using QSqlDatabase::lastError maybe that will reveal more about what is the problem with the open.
Also in your case return value from
QFile::exists("databases/juicemania.db")
QFile::exists("databases/juicemania.db")
To copy to clipboard, switch view to plain text mode
should be true if the file is in the correct location.
Bookmarks