8Observer8
24th August 2014, 11:42
Hi
This is my steps:
- I created the "Qt Widget Application"
- I opened the "MainWindow.ui" file and put on it the "mdiArea"
- I created the "Qt Designer Form Class" and wrote in the "MainWindow.h" and "MainWindow.cpp" files:
private:
Ui::MainWindow *ui;
FirstWindow *m_firstWindow;
SecondWindow *m_secondWindow;
ThirdWindow *m_thirdWindow;
MainWindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_firstWindow = new FirstWindow;
m_secondWindow = new SecondWindow;
m_thirdWindow = new ThirdWindow;
QMdiSubWindow *w1 = ui->mdiArea->addSubWindow( m_firstWindow );
ui->mdiArea->addSubWindow( m_secondWindow );
ui->mdiArea->addSubWindow( m_thirdWindow );
ui->mdiArea->cascadeSubWindows();
w1->resize( 500, 500 );
}
- I opened "FirstWindow.h" and "FirstWindow.cpp" files and wrote:
FirstWindow.h
private:
Ui::FirstWindow *ui;
void keyPressEvent( QKeyEvent *event );
};
FirstWindow.cpp
void FirstWindow::keyPressEvent(QKeyEvent *event)
{
qDebug() << "keyPressEvent";
}
- I ran the application and pressed on the keys. But I didn't see the text "keyPressEvent" on the "Application Output"
Thank you!
This is my steps:
- I created the "Qt Widget Application"
- I opened the "MainWindow.ui" file and put on it the "mdiArea"
- I created the "Qt Designer Form Class" and wrote in the "MainWindow.h" and "MainWindow.cpp" files:
private:
Ui::MainWindow *ui;
FirstWindow *m_firstWindow;
SecondWindow *m_secondWindow;
ThirdWindow *m_thirdWindow;
MainWindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_firstWindow = new FirstWindow;
m_secondWindow = new SecondWindow;
m_thirdWindow = new ThirdWindow;
QMdiSubWindow *w1 = ui->mdiArea->addSubWindow( m_firstWindow );
ui->mdiArea->addSubWindow( m_secondWindow );
ui->mdiArea->addSubWindow( m_thirdWindow );
ui->mdiArea->cascadeSubWindows();
w1->resize( 500, 500 );
}
- I opened "FirstWindow.h" and "FirstWindow.cpp" files and wrote:
FirstWindow.h
private:
Ui::FirstWindow *ui;
void keyPressEvent( QKeyEvent *event );
};
FirstWindow.cpp
void FirstWindow::keyPressEvent(QKeyEvent *event)
{
qDebug() << "keyPressEvent";
}
- I ran the application and pressed on the keys. But I didn't see the text "keyPressEvent" on the "Application Output"
Thank you!