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;
private:
Ui::MainWindow *ui;
FirstWindow *m_firstWindow;
SecondWindow *m_secondWindow;
ThirdWindow *m_thirdWindow;
To copy to clipboard, switch view to plain text mode
MainWindow.cpp
MainWindow
::MainWindow(QWidget *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 );
}
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 );
}
To copy to clipboard, switch view to plain text mode
- I opened "FirstWindow.h" and "FirstWindow.cpp" files and wrote:
FirstWindow.h
private:
Ui::FirstWindow *ui;
};
private:
Ui::FirstWindow *ui;
void keyPressEvent( QKeyEvent *event );
};
To copy to clipboard, switch view to plain text mode
FirstWindow.cpp
void FirstWindow
::keyPressEvent(QKeyEvent *event
) {
qDebug() << "keyPressEvent";
}
void FirstWindow::keyPressEvent(QKeyEvent *event)
{
qDebug() << "keyPressEvent";
}
To copy to clipboard, switch view to plain text mode
- I ran the application and pressed on the keys. But I didn't see the text "keyPressEvent" on the "Application Output"
Thank you!
Bookmarks