I am attempting within my code to connect to an SQLite database:
bool MainWindow::connOpen(){
mydb=QSqlDatabase::addDatabase("QSQLITE");
//qDebug ( ) << QSqlDatabase::drivers();
QString dbpath = "dbname.sqlite";
mydb.setDatabaseName(dbpath);
}
Which gives me the error message:
QSqlDatabase: QSQLITE driver not loaded
As well as an error window:
Driver not Loaded Driver not Loaded
The QSqlDatabase mydb declaration is in the MainWindow header file.
Strangely, this only happens in Debug Mode, in Release Mode, everything is fine. Even weirder, this used to work before (I think) an automatic Qt Update.
I am using:
- Qt Creator 4.4.1
- Qt 5.9.2.
Also, I checked the sqlite.dll is within the sqldrivers folders, where I understand it should be. But for some reason the Qt Folder is called Qt 5.9.1, unlike my actual version, only this does not seem to have any effect. Everything else works fine.
Also, when I uncomment the QSqlDatabase::drivers(); line, the output in Debug Mode is:
()
While in Release Mode, I get:
("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
Clearly, the drivers are not being found.
Where does the difference between debug and release could come from?