Having a QSqlDatabase as a class member and avoid the connection still in use warning
Hi,
I have a class that has a QSqlDatabase as a private member.
I use m_database in several functions of the class like:
However in the destructor of the class I remove the connection with
Code:
m_database.close();
But I always get the warning "MyConnection' is still in use, all queries will cease to work."
How can I avoid the warning?
Re: Having a QSqlDatabase as a class member and avoid the connection still in use war
Set the database object to an empty one before removing the database:
Code:
m_database.close();
const QString cname
= m_database.
connectionName();