qt5--模态对话框和非模态对话框
需要 #include <QDialog>
this->resize(500,400); this->setWindowTitle("主窗口"); QDialog d(this); d.resize(200,200); d.setWindowTitle("模态还是非模态"); d.exec();//显示对话框--模态---阻塞 QDialog* d1=new QDialog; d1->show(); //显示对话框--非模态---非阻塞
this->resize(500,400); this->setWindowTitle("主窗口"); QDialog* d=new QDialog(this); d->setStyleSheet("background-color: rgb(255, 251, 100)"); d->setWindowModality(Qt::NonModal); //设置模态或非模态 /*Qt::ApplicationModal 模态 Qt::NonModal 非模态 Qt::WindowModal 半模态:窗口级模态对话框,阻塞父窗口、父窗口的父窗口及兄弟窗口 */ d->show();