Dear All,

I come back to a very popular error-message. I tried out a lot. I RTFM. I have no clue how to avoid the following mesage if dataGrabber is destrouyed.

QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
Qt Code:
  1. class dataGrabber : public QObject
  2. {
  3. Q_OBJECT
  4. public:
  5. explicit dataGrabber(QObject *parent = nullptr);
  6. ~dataGrabber();
  7.  
  8. private:
  9. QSqlQuery *query;
  10.  
  11. public slots:
  12. bool openDatabase();
  13. bool closeDatabase();
  14. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. bool dataGrabber::openDatabase(){
  2.  
  3. dB = QSqlDatabase::addDatabase("QODBC");
  4. dB.setHostName("localhost");
  5. dB.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};"
  6. "DSN='';DBQ=" + dbPath + ";");
  7.  
  8. if(dB.open()){
  9. query = new QSqlQuery(dB); // open dB and prepare query
  10. prepareQuery();
  11. return true;
  12. {
  13. else{
  14. QMessageBox::warning(0, "Failure !", dB.lastError().text(), "OK");
  15. return false;
  16. }
  17.  
  18. return true;
  19. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. bool dataGrabber::closeDatabase(){
  2.  
  3. query->finish();
  4. query->clear();
  5.  
  6. delete query;
  7.  
  8. dB.close();
  9.  
  10. return true;
  11. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. dataGrabber::~dataGrabber(){
  2.  
  3. dB.removeDatabase("qt_sql_default_connection");
  4. }
To copy to clipboard, switch view to plain text mode 


As always, every help highly appreciated.

Cheers and thanks.