The dialog box is divided into
modal dialog box ( You cannot operate on other windows )
modeless dialog box ( You can operate on other windows )
#include "mainwindow.h" #include "ui_mainwindow.h" #include "QDialog" #include
"QDebug" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new
Ui::MainWindow) { ui->setupUi(this);
connect(ui->actionnew,&QAction::triggered,[=](){ // modal dialog box QDialog *dlg=new
QDialog(this); dlg->resize(300,200); dlg->exec();// block qDebug()<<" modality "; }); }
MainWindow::~MainWindow() { delete ui; }
Modal dialog through
dlg->exec();// block
1. Block to that line of code

At this time, click new to run without any output
2.

After closing , The following code is executed , And print it out

Two , modeless dialog box
#include "mainwindow.h" #include "ui_mainwindow.h" #include "QDialog" #include
"QDebug" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new
Ui::MainWindow) { ui->setupUi(this);
connect(ui->actionnew,&QAction::triggered,[=](){ // modeless dialog box QDialog *dlg2=new
QDialog(this); dlg2->resize(300,200); dlg2->show();
dlg2->setAttribute(Qt::WA_DeleteOnClose); qDebug()<<" Non modal "; }); }
MainWindow::~MainWindow() { delete ui; }
After operation

Technology
©2019-2020 Toolsou All rights reserved,
C Review of basic language knowledge Go Language learning notes (GUI programming )Java Misunderstanding —— Method overloading is a manifestation of polymorphism ? How to achieve low cost and high stability for cloud native applications ?elementui Shuttle box el-transfer Display list content text too long C/C++ Memory model Element-Ui assembly Message Message prompt , alert Popup C# Making a simplified version of calculator Python In pycharm editor Interface style modification Tiktok refresh progress bar ( Two little balls turn ), The code is simple