当前位置: 首页 > news >正文

QT对话框

QT对话框

模态

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDialog>
#include <QMessageBox>
#include <QDebug>
#include <QColorDialog>
#include <QFileDialog>
#include <QFontDialog>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //点击新建 创建对话框
    connect(ui->actionNew,&QAction::triggered,this,[=](){

        //对话框分类  模态对话框   非模态对话框
        //模态对话框  不可以对其他窗口进行操作
        //非模态对话框  可以对其他窗口进行操作

        //模态对话框创建
		 QDialog dlg(this);
		 dlg.resize(120,30);
		 dlg.exec();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

非模态

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDialog>
#include <QMessageBox>
#include <QDebug>
#include <QColorDialog>
#include <QFileDialog>
#include <QFontDialog>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //点击新建 创建对话框
    connect(ui->actionNew,&QAction::triggered,this,[=](){

        //对话框分类  模态对话框   非模态对话框
        //模态对话框  不可以对其他窗口进行操作
        //非模态对话框  可以对其他窗口进行操作

        //非模态对话框创建
        //创建为堆对象,避免作用域结束自动清除
		QDialog *dlg2 = new QDialog(this);
		dlg2->resize(120,30);
		dlg2->show();
		//设置 55号属性,窗口关闭时删除堆内存占用
		dlg2->setAttribute(Qt::WA_DeleteOnClose);

    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

相关文章:

  • 洛谷题单1-P5707 【深基2.例12】上学迟到-python-流程图重构
  • c++进阶之----哈希(桶)
  • 决策树原理详解
  • 3月30号
  • Windows10 下QT社区版的安装记录
  • 在 Vue 项目中快速集成 Vant 组件库
  • 磁盘冗余阵列
  • KMeans算法案例
  • 微服务架构中的精妙设计:服务注册/服务发现-Eureka
  • MySQL执行计划分析
  • MATLAB中rmfield函数用法
  • 中国网络安全产业分析报告
  • ngx_get_options
  • 鸿蒙HarmonyOS NEXT设备升级应用数据迁移流程
  • 算法刷题-最近公共祖先-LCA
  • 元编程思想
  • MySQL8.4 NDB Cluster 集群配置安装
  • 《K230 从熟悉到...》圆形检测
  • 推荐系统(二十):TensorFlow 中的两种范式 tf.keras.Model 和 tf.estimator.Estimator
  • playwright解决重复登录问题,通过pytest夹具自动读取storage_state用户状态信息
  • 网站开发是什么/廊坊关键词排名首页
  • 做网站建设公司企业/石家庄百度搜索引擎优化
  • wordpress安装教程视频教程/国内最好的seo培训
  • 2018年临沂建设局网站/营销网站有哪些
  • 济南市高新技术官方网站开发区/简述seo和sem的区别与联系
  • 中关村在线app/文大侠seo