QSqlDatabase中的removeDatabase

运行程序时出现提示:QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.

//在Db类中的构造函数中有以下定义
sqlite=QSqlDatabase::addDatabase("QSQLITE","sqlite_connection");
mysql=QSqlDatabase::addDatabase("QMYSQL","mysql_connection");

//在某处使用了Db类
Db * db=new Db();

//在db对象被delete掉后
if(db) 
    delete db;
{
     QSqlDatabase db1 = QSqlDatabase::database("sqlite_connection");
     QSqlQuery query1(QString(), db1);
     QSqlDatabase db2 = QSqlDatabase::database("sqlite_connection");
     QSqlQuery query2(QString(), db2);
}
QSqlDatabase::removeDatabase("sales");

你可能感兴趣的:(removeDatabase)