Hi all,

In my program i have a main class (kentrko) which creates a QSqlDatabase* object. I want to pass this object to a dialogue to detect whether the connection is opened or closed and if not to open it. The code works fine and compiles but i receive the following error when I am opening the dialogue window again:
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
kentriko class:
Qt Code:
  1. #include "kentriko.h"
  2. #include <QMdiSubWindow>
  3.  
  4. kentriko::kentriko(QWidget *parent)
  5. : QMainWindow(parent)
  6. {
  7. ui.setupUi(this);
  8. connect(ui.actionAnalisi, SIGNAL(triggered()), this, SLOT(anixe_analisi()));
  9. connect(ui.actionSindesi, SIGNAL(triggered()), this, SLOT(anixe_sindesi()));
  10. *db = QSqlDatabase::addDatabase("QMYSQL");
  11. }
  12.  
  13. void kentriko::anixe_sindesi(){
  14. sindesi *sindesi1= new sindesi(0,db) ;
  15. sindesi1->show();
  16. }
To copy to clipboard, switch view to plain text mode 

and the kentriko header:
Qt Code:
  1. #ifndef KENTRIKO_H
  2. #define KENTRIKO_H
  3. #include <QtGui/QMainWindow>
  4. #include "ui_kentriko.h"
  5. #include <QtSql>
  6. #include "../parathrira/sindesi/sindesi.h"// i klasi silogi ine orismeni apo tin sindesi giayto xreazete edo to header
  7. #include "../parathrira/analisi/analisi.h"
  8. class kentriko : public QMainWindow
  9. {
  10. Q_OBJECT
  11. public:
  12. kentriko(QWidget *parent = 0);
  13. ~kentriko();
  14. public slots:
  15. void anixe_analisi ();
  16. void anixe_sindesi ();
  17. };
To copy to clipboard, switch view to plain text mode 

the dialog that i want to pass the db and manipulate it is:

Qt Code:
  1. #ifndef SINDESI_H
  2. #define SINDESI_H
  3. #include <QtSql>
  4. #include <QtGui/QDialog>
  5. #include "ui_sindesi.h"
  6.  
  7. class sindesi : public QDialog
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. sindesi(QWidget *parent , QSqlDatabase* db);
  13. ~sindesi();
  14. public slots:
  15. void sindesou();
  16. void aposindesou();
  17.  
  18. private:
  19. Ui::sindesiClass ui;
  20. };
  21.  
  22. #endif // SINDESI_H
To copy to clipboard, switch view to plain text mode 

and the implementation:
Qt Code:
  1. #include "sindesi.h"
  2. #include <QtSql>
  3. sindesi::sindesi(QWidget *parent,QSqlDatabase* db)
  4. : QDialog(parent)
  5. {
  6. db3=db;
  7. ui.setupUi(this);
  8. connect(ui.sindesi, SIGNAL(clicked()), this, SLOT(sindesou()));
  9. connect(ui.aposindesi, SIGNAL(clicked()), this, SLOT(aposindesou()));
  10. }
  11. void sindesi::sindesou() {
  12. if (db3->isOpen())
  13. ui.pliroforia_2->setText("ine idi anixti");
  14. if (!db3->isOpen()) {
  15. db3->setDatabaseName(ui.pinakas->text());
  16. db3->setUserName(ui.onoma->text());
  17. db3->setPassword(ui.kodikos->text());
  18. db3->setHostName("127.0.0.1");
  19. db3->setPort(3306);
  20. if (!db3->open()) {
  21. ui.katastasi->setText("Not connected");
  22. } else {
  23. ui.katastasi->setText("connected");
  24. }
  25. } else {
  26. ui.katastasi->setText("It has already been connected");
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 
Any ideas why is this happening?

Many thanks in advance.