Hi and thank you. Your solution works well but I don't want to create a QSqlDatabase every time I need to make a query so I solved the problem using another solution.

Instead of removing the QSqlDatabase instance from my class I modified the destructor of the class. Now it looks like

Qt Code:
  1. DAO::~DAO()
  2. {
  3. this->db = QSqlDatabase();
  4. QSqlDatabase::removeDatabase(this->connName);
  5. }
To copy to clipboard, switch view to plain text mode 

On the firts instruction of the destructor, the reference to my database is destroyed so now I can remove the database with the removeDatabase function. Tested and working perfect: all the warnings gone!