Hello!
I've got a lot of help days ago to solve a problem on the heritage. Another one has arose on the same topic and I am getting stucking deeply in it. I have a child window heriting from its parent. While displaying the child window, I just obtain EXACTELY the parent window all the time, I mean the main window. I can't therefore get to the child window.

My questions:
1- Why do I obtain the same and the parent window while trying to display the child window?
2- Could someone help me overcoming the problem?

Many thanks in advance!

He is my code:

Parent.h
Qt Code:
  1. #ifndef DEF_HERITAGE
  2. #define DEF_HERITAGE
  3.  
  4. #include <QtGui>
  5.  
  6.  
  7. class Heritage: public QMainWindow
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. Heritage(QWidget *parent = 0);
  13. virtual ~Heritage();
  14.  
  15. public slots:
  16. virtual void openChildWindow();
  17.  
  18. protected:
  19. QStatusBar *m_barreEtat;
  20. QMenu *m_menuFile, *m_aide;
  21. QRadioButton *m_childButton;
  22. QPushButton *m_quitButton;
  23. QWidget *m_centralWidget;
  24. QRadioButton *m_unBouton;
  25. };
  26.  
  27. #endif // HERITAGE_H
To copy to clipboard, switch view to plain text mode 

Parent.cpp
Qt Code:
  1. #include "Heritage.h"
  2. #include "ChildWindow.h"
  3.  
  4. Heritage::Heritage(QWidget *parent):QMainWindow(parent)
  5. {
  6. m_centralWidget = new QWidget(this);
  7. m_centralWidget->setFixedSize(705, 390);
  8.  
  9. m_barreEtat = statusBar();
  10.  
  11. m_menuFile = menuBar()->addMenu("&File");
  12. m_aide = menuBar()->addMenu("&Help");
  13.  
  14. m_childButton = new QRadioButton("Open childwindow", m_centralWidget);
  15. m_childButton->move(50, 150);
  16.  
  17. m_quitButton = new QPushButton("Exit", m_centralWidget);
  18. m_quitButton->move(200, 150);
  19.  
  20.  
  21. connect(m_childButton, SIGNAL(clicked()), this, SLOT(openChildWindow()));
  22. connect(m_quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
  23.  
  24. setWindowTitle("Heritage");
  25. setCentralWidget(m_centralWidget);
  26.  
  27.  
  28. }
  29.  
  30. void Heritage::openChildWindow()
  31. {
  32. ChildWindow *childWindow = new ChildWindow(this);
  33. childWindow->show();
  34. }
  35.  
  36.  
  37. Heritage::~Heritage()
  38. {
  39. ;
  40. }
To copy to clipboard, switch view to plain text mode 

Child.h
Qt Code:
  1. #ifndef DEF_CHILDWINDOW
  2. #define DEF_CHILDWINDOW
  3.  
  4. #include<QtGui>
  5.  
  6. #include "Heritage.h"
  7.  
  8. class ChildWindow: public Heritage
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. ChildWindow(QWidget *parent = 0);
  14. virtual ~ChildWindow();
  15.  
  16. public slots:
  17.  
  18.  
  19. private:
  20. QPushButton *m_childButton;
  21.  
  22. };
  23.  
  24. #endif // CHILDWINDOW_H
To copy to clipboard, switch view to plain text mode 

Child.cpp
Qt Code:
  1. #include "ChildWindow.h"
  2.  
  3. ChildWindow::ChildWindow(QWidget *parent):Heritage(parent)
  4. {
  5. this->setFixedSize(300, 150);
  6. this->setWindowTitle("Child window");
  7.  
  8. m_childButton = new QPushButton("Exit", this);
  9. m_childButton->move(50, 75);
  10.  
  11.  
  12. connect(m_childButton, SIGNAL(clicked()), this, SLOT(close()));
  13. }
  14.  
  15. ChildWindow::~ChildWindow()
  16. {
  17. ;
  18. }
To copy to clipboard, switch view to plain text mode 

main
Qt Code:
  1. #include <QApplication>
  2. #include "Heritage.h"
  3. #include <QtGui>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication app(argc, argv);
  8. Heritage wind;
  9.  
  10. wind.show();
  11.  
  12. return app.exec();
  13.  
  14. }
To copy to clipboard, switch view to plain text mode