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 ist fine. Even weirder, this used to work before (I think) an automatic QT Update. I am using QTCreator 4.4.1 and 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.
Does anybody have an idea where the difference betweeen debug and release could come from? Thanks a lot!
qsqlited.dllas well (note the d suffix)? If it's missing, your Qt installation is propably broken. In that case you need to reinstall Qt (make shure to use the online installer) - Felix