When the qsqldatabase::adddatabase is first run, a default connection is generated while generating the SQLite file:
Qsqldatabase database = Qsqldatabase::adddatabase ("Qsqlite");
QString myconn = M_createname = Database.connectionname ();
Database.setdatabasename (myfile);
However, when a real query is made, a new connection is used:
M_database = Qsqldatabase::adddatabase ("Qsqlite", "Mynewconn");
M_database.setdatabasename (Mysqlfile);
In some cases, if you want to delete this database file, you must also close the Mynewconn except to close the myconn, otherwise you will not be able to access the database file, resulting in the inability to delete.
How do I deactivate a database connection? Use:
Http://doc.qt.io/qt-5/qsqldatabase.html#removeDatabase
It's a little complicated, and it takes a closer look to understand.
When the qsqldatabase::adddatabase is first run, a default connection is generated while generating the SQLite file