QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(databaseFileName); db.open();... db.close();
QSqlDatabase db = QSqlDatabase::database(); if(db.isValid()) { if(db.isOpen()) db.close(); QString connectionName = db.connectionName(); db = QSqlDatabase(); QSqlDatabase::removeDatabase(connectionName); }