Qt链接sqlite数据库问题。一直提示'qt_sql_default_connection' is still in use
我定义了一个数据库操作类。
在DataBaseServer.h里面定义了一个 private : QSqlDatabase db;
然后在DataBaseServer.cpp里面
DataBaseServer::DataBaseServer()
{
bool cc = !QFile::exists("wardb.db");
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("wardb.db");
if ( !db.open())
{
QMessageBox::critical(NULL, "failed", "Connect failed.");
}
if(cc)
QMessageBox::critical(NULL, "not exit", "Connect failed.");
}
QSqlQuery query;
if (!(query.exec("SELECT Uname FROM war_user")))
{
QMessageBox::critical(NULL, "query", " failedaaa.");
return -1;
}