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

QDialog-基础讲解

注意:前面都是基础讲解,如果有什么不懂的可以看看,但是如果只是想看实际运用场景,建议只看自定义案例

这里是目录标题

  • 自定义案例
  • 问题互动
  • 案例互动

The QDialog class is the base class of dialog windows
QDialog 类是对话框窗口的基类

详细解释
A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user. QDialogs may be modal or modeless. QDialogs can provide a return value, and they can have default buttons. QDialogs can also have a QSizeGrip in their lower-right corner, using setSizeGripEnabled().Note that QDialog (and any other widget that has type Qt::Dialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent’s top-level widget (if it is not top-level itself). It will also share the parent’s taskbar entry.
Use the overload of the QWidget::setParent() function to change the ownership of a QDialog widget. This function allows you to explicitly set the window flags of the reparented widget; using the overloaded function will clear the window flags specifying the window-system properties for the widget (in particular it will reset the Qt::Dialog flag).
Note: The parent relationship of the dialog does not imply that the dialog will always be stacked on top of the parent window. To ensure that the dialog is always on top, make the dialog modal. This also applies for child windows of the dialog itself. To ensure that child windows of the dialog stay on top of the dialog, make the child windows modal as well.

对话框窗口是主要用于短期任务和与用户简短交流的顶层窗口。QDialog可以是模态或非模态的,能够提供返回值并设置默认按钮。通过在右下角启用setSizeGripEnabled(),QDialog还可以包含尺寸调整手柄。需注意QDialog(以及任何具有Qt::Dialog类型的部件)对父部件的处理方式与Qt其他类略有不同:对话框始终是顶层部件,但若设置了父部件,其默认位置将居中显示在父部件的顶层窗口之上(若父部件本身非顶层)。对话框还会共享父部件的任务栏条目。通过QWidget::setParent()函数的重载版本可变更QDialog部件的所有权关系,该函数允许显式设置重新指定父部件后的窗口标志;使用重载函数将清除指定部件窗口系统属性的标志(特别是会重置Qt::Dialog标志)。
注意:对话框的父级关系并不意味着对话框始终堆叠在父窗口之上。要确保对话框始终置顶,需将其设为模态。此规则同样适用于对话框自身的子窗口——要使对话框的子窗口保持置顶状态,也需将这些子窗口设为模态。

自定义案例

MaintenanceDialog::MaintenanceDialog(QWidget*parent):QDialog(parent){setWindowTitle("个人信息记录");setMinimumSize(500,400);QFormLayout*formLayout=newQFormLayout();m_adaptationParams=newQLineEdit(this);m_softwareUpdate=newQLineEdit(this);m_calibrationProcess=newQLineEdit(this);m_keyComponentTestParams=newQLineEdit(this);m_replacementInfo=newQLineEdit(this);formLayout->addRow("姓名:",m_adaptationParams);formLayout->addRow("年龄:",m_softwareUpdate);formLayout->addRow("性别:",m_calibrationProcess);formLayout->addRow("爱好:",m_keyComponentTestParams);formLayout->addRow("目标:",m_replacementInfo);m_saveButton=newQPushButton("保存",this);QVBoxLayout*mainLayout=newQVBoxLayout(this);mainLayout->addLayout(formLayout);mainLayout->addWidget(m_saveButton,0,Qt::AlignRight);setLayout(mainLayout);connect(m_saveButton,&QPushButton::clicked,this,&MaintenanceDialog::onSaveButtonClicked);}

问题互动

弹出来的界面,被置顶后,原有界面是否还会存在?

假设存在,如下图,有什么办法,在没有完成当前界面任务前,不能使之点击其它任务?
揭秘:

voidMainWindow::onShowMaintenanceDialog(){m_dialog->exec();}

案例互动

qt-弹框提示-界面提醒

http://www.cnnetsun.cn/news/27971.html

相关文章:

  • Day28~实现strlen、strcpy、strncpy、strcat、strncat
  • 空洞骑士模组管理大师课:5个关键技巧让Scarab成为你的游戏管家
  • 实用方法:轻松实现NCM文件格式转换的完整解析
  • C++课后习题训练记录Day49
  • LeetCode 189. 旋转数组 | 三步反转最优解全拆解
  • downkyi视频下载:告别卡顿与画质损失的终极解决方案
  • 教你如何玩转DPDK开发中的KNI与内核交互,让网络速度翻倍!
  • Openresty驱动下的高性能Web网关实战
  • 百度网盘下载工具终极指南:快速突破限速的完整教程
  • C语言实现hashmap(附带源码)
  • jsonnet介绍和使用
  • 喜马拉雅音频数据采集:API接口分析与加密音频链接解密实战
  • 角色影像生成新纪元:Pony V7-Base引领AI创作革命
  • 论文格式修改排名:9大平台+在线一键优化
  • 论文写作效率低?十大AI生成平台,AIGC降重+赶due不熬夜
  • 文献引用规范考核要点解析与实践指南
  • 文献综述写作期末指南:方法、结构与常见问题解析
  • 期末文献研究论文的撰写方法与实践路径探讨
  • 基于 HID 协议的扩展功能指令定义方案
  • 模拟IC设计:集成电路与运算放大器大观
  • 6、Oracle数据库管理:文件与目录操作全解析
  • 12、Oracle数据库Linux服务器软件管理全攻略
  • 某聘新版AST解混淆(青春版)
  • 基于Spring Boot框架和vue的的诗词鉴赏与交流网站的设计与实现_96fdvu1s
  • 基于模型预测算法的混合储能微电网双层能量管理系统研究(Matlab代码实现)
  • 三极管:电子信息时代的核心“控制单元”,藏于设备中的关键器件
  • 1小时打造专属右键菜单工具:快马平台实战
  • 零基础用AI制作第一个Macyy风格网页
  • GG3M业务核心:需求满足与问题解决 | GG3M Business Core: Demand Satisfaction and Problem Solving
  • 零基础玩转Vulhub:从安装到第一个漏洞复现