1.继承自QWidge的窗口的呈现,作为tabPage呈现,作为独立窗口呈现
2.继承自QMainWindow的窗口的呈现,作为abPage呈现,作为独立窗口呈现
1. 继承自QWidge的窗口的呈现
1.1 作为tabPage呈现
void MutiWindowExample::on_actWidgetInsite_triggered()
{TFormDoc *form = new TFormDoc(this);//关闭时 自动删除 释放form->setAttribute(Qt::WA_DeleteOnClose);int cur= ui->tabWidget->addTab(form,QString::asprintf("Doc %d",ui->tabWidget->count()));ui->tabWidget->setVisible(true);connect(form,&TFormDoc::titleChanged,this,&MutiWindowExample::do_changeTabTitle);
}
1.2 作为独立窗口呈现
void MutiWindowExample::on_actWidget_triggered()
{TFormDoc *form = new TFormDoc(this);//关闭时 自动删除 释放form->setAttribute(Qt::WA_DeleteOnClose);form->setWindowTitle("基于Widget的窗口,无父窗口,关闭时删除释放");//设置成window 窗口标识form->setWindowFlag(Qt::Window,true);form->setWindowOpacity(0.9);//独立窗口显示form->show();
}
2. 继承自QMainWindow的窗口的呈现
2.1 作为tabPage呈现
void MutiWindowExample::on_actWindowInsite_triggered()
{CustomDialogExample *form = new CustomDialogExample(this);form->setAttribute(Qt::WA_DeleteOnClose);//关闭立即释放int cur = ui->tabWidget->addTab(form,QString::asprintf("Table %d",ui->tabWidget->count()));ui->tabWidget->setCurrentIndex(cur);ui->tabWidget->setVisible(true);
}
2.2 作为独立窗口呈现
void MutiWindowExample::on_actWindow_triggered()
{CustomDialogExample *form = new CustomDialogExample(this);form->setAttribute(Qt::WA_DeleteOnClose);//关闭立即释放form->setWindowTitle("基于QMainWindow的窗口");form->statusBar();form->show();
}