I got this error, every time a reopen or open a new database file:
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
Sometimes I get lazy and ask google first. This time google didn't tell me.
A few noobs like me had the same issue. There was discussion about that, but they actually was digging to deep!
Load driver only once:
And then, the database file you can close and open multiple times:
qDebug() << db.lastError();
qDebug() << db.tables();