Hi,
I have a class that has a QSqlDatabase as a private member.
private:
private:
QSqlDatabase m_database;
To copy to clipboard, switch view to plain text mode
I use m_database in several functions of the class like:
..
delete query;
QSqlQuery *query = new QSqlQuery(m_database);
..
delete query;
To copy to clipboard, switch view to plain text mode
However in the destructor of the class I remove the connection with
m_database.close();
m_database.close();
QSqlDatabase::removeDatabase("MyConnection");
To copy to clipboard, switch view to plain text mode
But I always get the warning "MyConnection' is still in use, all queries will cease to work."
How can I avoid the warning?
Bookmarks