Hi,

I have a class that has a QSqlDatabase as a private member.

Qt Code:
  1. private:
  2. QSqlDatabase m_database;
To copy to clipboard, switch view to plain text mode 

I use m_database in several functions of the class like:

Qt Code:
  1. QSqlQuery *query = new QSqlQuery(m_database);
  2.  
  3. ..
  4.  
  5. delete query;
To copy to clipboard, switch view to plain text mode 

However in the destructor of the class I remove the connection with
Qt Code:
  1. m_database.close();
  2. 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?