Hello again!

I have following code:

Qt Code:
  1. CBrowserWindow::CBrowserWindow(QWidget *parent, MySQLConnect* pDataBase, QString sTableName)
  2. : QWidget(parent)
  3. {
  4. Q_CHECK_PTR(pDataBase); // if database connection is NULL, we have a big problem
  5.  
  6. m_pModel=new QSqlRelationalTableModel(this); // creates new model
  7. Q_CHECK_PTR(m_pModel); // checks for succesful creation
  8. m_pModel->setTable(sTableName); // sets table name
  9.  
  10. m_pColumnNames=new QStringList(); // creates new string list
  11. Q_CHECK_PTR(m_pColumnNames); // checks for succesful creation
  12.  
  13. // fetches record
  14. m_pTableRecord=new QSqlRecord(); // creates new record
  15. Q_CHECK_PTR(m_pTableRecord); // checks for susccesful creation
  16. //m_pTableRecord=&pDataBase->m_pDatabase->record(sTableName); // fetches column names
  17. m_pTableRecord=&pDataBase->m_pDatabase->record(sTableName); // fetches column names
  18.  
  19.  
  20. if (!m_pTableRecord->isEmpty()) {
  21. for (m_iIndex=0; m_iIndex<m_pTableRecord->count(); m_iIndex++) {
  22. m_pColumnNames->append(m_pTableRecord->fieldName(m_iIndex));
  23. }
  24. } // if
  25.  
  26. createBrowserContens(pDataBase, m_pColumnNames); // creates browser controls
  27.  
  28. delete m_pModel; // deletes pModel;
  29. delete m_pTableRecord; // deletes m_pTableRecord
  30. // just to be sure
  31. m_pModel=0;
  32. m_pTableRecord=0;
  33. }
To copy to clipboard, switch view to plain text mode 
and in the line
Qt Code:
  1. m_pTableRecord=&pDataBase->m_pDatabase->record(sTableName); // fetches column names
To copy to clipboard, switch view to plain text mode 
I get segmentation fault. What I am trying to do is to dynamically fetch table column names from mysql database and then create table widget for record display. Why do I get segfault?

Here is class description:
Qt Code:
  1. class CBrowserWindow : public QWidget
  2. {
  3. Q_OBJECT
  4. public:
  5. CBrowserWindow(QWidget *parent = 0, MySQLConnect* pDataBase=0, QString sTableName="");
  6.  
  7. ~CBrowserWindow();
  8.  
  9. private:
  10. QStringList* m_pColumnNames; // column names for selected database
  11.  
  12. private:
  13. // buttons
  14. QPushButton* m_pButtonAdd; // button for addition of record
  15. QPushButton* m_pButtonChange; // button for change of record
  16. QPushButton* m_pButtonDelete; // button for deletion of record
  17. QPushButton* m_pButtonSelect; // button for selection of record
  18.  
  19. private:
  20. // layouts
  21. QHBoxLayout* m_pHorizLayout; // horizontal leyout
  22. QVBoxLayout* m_pVertLayout; // vertical layout
  23.  
  24. private:
  25. // mebmers needed for column idetification
  26. QSqlRelationalTableModel* m_pModel; // pointer to pmodel
  27. QSqlRecord* m_pTableRecord; // pointer to database record
  28. QTableView* m_pView; // pointer to view
  29. QGridLayout* m_pGridLayout; // pointer to grid layout
  30. quint16 m_iIndex; // index in for loops - this type is guaranteed to be 16-bit on all platforms supported by Qt
  31.  
  32. private:
  33. // private methods
  34. void createBrowserContens(MySQLConnect* pDatabase, QStringList* pColumnNames); // creates table on widget
  35. };
  36.  
  37. #endif
To copy to clipboard, switch view to plain text mode