Hi,

i have a QT application with QSqlDatabase . This is what i do :

in cmasterlist.h i have a class with m_db member
Qt Code:
  1. class CMasterList : public QObject
  2. {
  3. private:
  4. public:
  5. void memberfunction ();
  6. }
To copy to clipboard, switch view to plain text mode 

in cmasterlist.c i have a memberfunction
Qt Code:
  1. void CMasterList::memberfunction ()
  2. {
  3. if(!m_db.isOpen())return;
  4. ...
  5. }
To copy to clipboard, switch view to plain text mode 

in main.h i have a class where i create a CMasterList member. Main.h and Main.c is the main class for my ui application which means the destructor is only called when i close the application.
Qt Code:
  1. class Cmain : public QMainWindow
  2. {
  3. private:
  4. CMasterList m_MasterList;
  5. }
To copy to clipboard, switch view to plain text mode 

in the construtor of Cmain i first open the db m_db .

the problem that i have :
when i call m_MasterList.memberfunction in the constructor the database is open and memberfunction can run normally, but when i call m_MasterList.memberfunction in a memberfunction of Cmain, then m_db.isOpen() returns false?

I have put a breakpoint at m_db.close(); wich confirms that the close function is only called when i close the application.

I have no idea why the database closes before i close the ui?