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
Code:
#ifndef DEF_HERITAGE #define DEF_HERITAGE #include <QtGui> { Q_OBJECT public: virtual ~Heritage(); public slots: virtual void openChildWindow(); protected: QStatusBar *m_barreEtat; QRadioButton *m_childButton; QPushButton *m_quitButton; QWidget *m_centralWidget; QRadioButton *m_unBouton; }; #endif // HERITAGE_H
Parent.cpp
Code:
#include "Heritage.h" #include "ChildWindow.h" { m_centralWidget->setFixedSize(705, 390); m_barreEtat = statusBar(); m_menuFile = menuBar()->addMenu("&File"); m_aide = menuBar()->addMenu("&Help"); m_childButton->move(50, 150); m_quitButton->move(200, 150); connect(m_childButton, SIGNAL(clicked()), this, SLOT(openChildWindow())); connect(m_quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); setWindowTitle("Heritage"); setCentralWidget(m_centralWidget); } void Heritage::openChildWindow() { ChildWindow *childWindow = new ChildWindow(this); childWindow->show(); } Heritage::~Heritage() { ; }
Child.h
Code:
#ifndef DEF_CHILDWINDOW #define DEF_CHILDWINDOW #include<QtGui> #include "Heritage.h" class ChildWindow: public Heritage { Q_OBJECT public: virtual ~ChildWindow(); public slots: private: QPushButton *m_childButton; }; #endif // CHILDWINDOW_H
Child.cpp
Code:
#include "ChildWindow.h" { this->setFixedSize(300, 150); this->setWindowTitle("Child window"); m_childButton->move(50, 75); connect(m_childButton, SIGNAL(clicked()), this, SLOT(close())); } ChildWindow::~ChildWindow() { ; }
main
Code:
#include <QApplication> #include "Heritage.h" #include <QtGui> int main(int argc, char *argv[]) { Heritage wind; wind.show(); return app.exec(); }