mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//点击new按钮 弹出一个对话框 模块对话框
connect(ui->actionnew, &QAction::triggered, this,[=](){
//对话框分类
//模态对话框(不可以对其他窗口进行操作)
//非模态对话框(可以对其他窗口进行操作)
//模态创建
QDialog dlg(this);
dlg.resize(600, 400);
qDebug() << "模态的对话框弹出了" ;
dlg.exec();
});
//点击open按钮 弹出一个非模态对话框
connect(ui->actionopen, &QAction::triggered, this, [=](){
QDialog * dlg = new QDialog(this);
dlg->resize(600, 400);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
qDebug() << "非模态的对话框弹出了" ;
});
}
MainWindow::~MainWindow()
{
delete ui;
}