feat: Qt MDI(Multi-document Interface)
This commit is contained in:
parent
537ba09214
commit
2160977193
@ -75,3 +75,74 @@ void ExMainWindow::on_actOpen_triggered()
|
||||
ui->actPaste->setEnabled(true);
|
||||
ui->actFont->setEnabled(true);
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actQuit_triggered()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actNew_triggered()
|
||||
{
|
||||
ExMDI *mdi = new ExMDI(this);
|
||||
ui->mdiArea->addSubWindow(mdi); //添加一个子窗口MDI
|
||||
mdi->show();
|
||||
|
||||
ui->actCopy->setEnabled(true);
|
||||
ui->actCut->setEnabled(true);
|
||||
ui->actPaste->setEnabled(true);
|
||||
ui->actFont->setEnabled(true);
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actFont_triggered()
|
||||
{
|
||||
ExMDI* mdi = (ExMDI *)ui->mdiArea->activeSubWindow()->widget();
|
||||
mdi->setEditFont(); //设置编写的字体文档
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actCut_triggered()
|
||||
{
|
||||
ExMDI* mdi = (ExMDI *)ui->mdiArea->activeSubWindow()->widget();
|
||||
mdi->textCut();
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actCopy_triggered()
|
||||
{
|
||||
ExMDI* mdi = (ExMDI *)ui->mdiArea->activeSubWindow()->widget();
|
||||
mdi->textCopy();
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actPaste_triggered()
|
||||
{
|
||||
ExMDI* mdi = (ExMDI *)ui->mdiArea->activeSubWindow()->widget();
|
||||
mdi->textPaste();
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actView_triggered(bool checked) //MDI 模式设置
|
||||
{
|
||||
if (checked) { //Tab多页显示模式
|
||||
ui->mdiArea->setViewMode(QMdiArea::TabbedView);
|
||||
ui->mdiArea->setTabsClosable(true); //页面可以关闭
|
||||
ui->actCascade->setEnabled(false);
|
||||
ui->actTile->setEnabled(false);
|
||||
} else {
|
||||
ui->mdiArea->setViewMode(QMdiArea::SubWindowView); //子窗口模式
|
||||
ui->actCascade->setEnabled(true);
|
||||
ui->actTile->setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actCascade_triggered()
|
||||
{
|
||||
ui->mdiArea->cascadeSubWindows(); //窗口级联展开
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actTile_triggered()
|
||||
{
|
||||
ui->mdiArea->tileSubWindows(); //平铺展开
|
||||
}
|
||||
|
||||
void ExMainWindow::on_actClose_triggered()
|
||||
{
|
||||
ui->mdiArea->closeAllSubWindows(); //关闭全部子窗口
|
||||
}
|
||||
|
@ -43,7 +43,17 @@ public:
|
||||
~ExMainWindow();
|
||||
|
||||
private slots:
|
||||
void on_actOpen_triggered();
|
||||
void on_actOpen_triggered(); //打开文档
|
||||
void on_actQuit_triggered(); //退出程序
|
||||
void on_actNew_triggered(); //新建MDI的子窗口
|
||||
void on_actFont_triggered(); //设置字体
|
||||
void on_actCut_triggered(); //剪切文本
|
||||
void on_actCopy_triggered(); //复制文本
|
||||
void on_actPaste_triggered(); //粘贴文本
|
||||
void on_actView_triggered(bool checked); //MDI显示: Table 和 子窗口页面显示
|
||||
void on_actCascade_triggered();//级联显示
|
||||
void on_actTile_triggered(); //平铺显示
|
||||
void on_actClose_triggered(); //关闭所有子窗口
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent *e); //主窗口关闭时关闭所有子窗口
|
||||
|
Loading…
Reference in New Issue
Block a user