要显示两个QMainWindow 可以给第二个QMainWindow 添加:
public:
/*!
* \brief exec 类似于 QDialog 中的 exec 显示模式
*/
void exec();
protected:
/*!
* \brief closeEvent 关闭事件,监控窗口的关闭操作
* 主要是为了退出事件循环
* \param event
*/
void closeEvent(QCloseEvent *event);
/*!* \brief m_eventLoop 事件循环,用来实现 exec*/QEventLoop *m_eventLoop;
void Class::exec()
{
setWindowModality(Qt::ApplicationModal);
show();
m_eventLoop->exec();
}
void Class::closeEvent(QCloseEvent *event)
{
/*
* TODO 它可代替 TbarClose_Click 的功能
*/
m_eventLoop->exit();
return QMainWindow::closeEvent(event);
}