Hi,
i have a QT application with QSqlDatabase . This is what i do :
in cmasterlist.h i have a class with m_db member
{
private:
public:
void memberfunction ();
}
class CMasterList : public QObject
{
private:
QSqlDatabase m_db;
public:
void memberfunction ();
}
To copy to clipboard, switch view to plain text mode
in cmasterlist.c i have a memberfunction
void CMasterList::memberfunction ()
{
if(!m_db.isOpen())return;
...
}
void CMasterList::memberfunction ()
{
if(!m_db.isOpen())return;
...
}
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.
{
private:
CMasterList m_MasterList;
}
class Cmain : public QMainWindow
{
private:
CMasterList m_MasterList;
}
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?
Bookmarks