QT的常用对话框的应用
QMessageBox类提供了常用的弹出式对话框:提示、警告、错误、询问、关于对话框
需要添加头文件
#include <QMessageBox>
MESSAGE 是要是显示的字符串
void Dialog::criticalMessage()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::critical(this, tr("QMessageBox::critical()"),
MESSAGE,
QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore);
if (reply == QMessageBox::Abort)
criticalLabel->setText(tr("Abort"));
else if (reply == QMessageBox::Retry)
criticalLabel->setText(tr("Retry"));
else
criticalLabel->setText(tr("Ignore"));
} void Dialog::informationMessage()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE);
if (reply == QMessageBox::Ok)
informationLabel->setText(tr("OK"));
else
informationLabel->setText(tr("Escape"));
} void Dialog::questionMessage()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, tr("QMessageBox::question()"),
MESSAGE,
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if (reply == QMessageBox::Yes)
questionLabel->setText(tr("Yes"));
else if (reply == QMessageBox::No)
questionLabel->setText(tr("No"));
else
questionLabel->setText(tr("Cancel"));
} void Dialog::warningMessage()
{
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
MESSAGE, , this);
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
if (msgBox.exec() == QMessageBox::AcceptRole)
warningLabel->setText(tr("Save Again"));
else
warningLabel->setText(tr("Continue")); }
QT的常用对话框的应用的更多相关文章
- 第八章 Qt GUI之对话框使用
第八章 Qt GUI之对话框使用 对话框可以是模态(modal)的或非模态(modeless)两种.当我们在一个用户界面程序里面对一个对话框(比如选择文件对话框)的操作没有结束前,界面的其他窗口无法操 ...
- QT学习 之 对话框 (四) 字体对话框、消息对话框、文件对话框、进程对话框(超详细中文注释)
QMessageBox类: 含有Question消息框.Information消息框.Warning消息框和Critical消息框等 通常有两种方式可以来创建标准消息对话框: 一种是采用“基于属性”的 ...
- android常用对话框封装
在android开发中,经常会用到对话框跟用户进行交互,方便用户可操作性:接下来就对常用对话框进行简单封装,避免在项目中出现冗余代码,加重后期项目的维护量:代码如有问题欢迎大家拍砖指正一起进步. 先贴 ...
- Android 常用对话框Dialog封装
Android 6种 常用对话框Dialog封装 包括: 消息对话框.警示(含确认.取消)对话框.单选对话框. 复选对话框.列表对话框.自定义视图(含确认.取消)对话框 分别如下图所示: ...
- Qt creator 常用的快捷健
Qt creator 常用的快捷健 F1 查看帮助F2 跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2 声明和定义之间切换F4 头文件 ...
- matlab GUI之常用对话框(四)-- 输入对话框 inputdlg、目录对话框 uigetdir、列表对话框 listdlg
常用对话框(四) 1.输入对话框 inputdlg answer = inputdlg(prompt) answer = inputdlg(prompt,dlg_title) answer = in ...
- matlab GUI之常用对话框(二)-- 进度条的使用方法
常用对话框(二) 进度条 waitbar 调用格式: h = waitbar(x,'message') waitbar(x,'message','CreateCancelBtn','button ...
- matlab GUI之常用对话框(一)-- uigetfile\ uiputfile \ uisetcolor \ uisetfont
常用对话框(一) 1.uigetfile 文件打开对话框 调用格式: [FileName,PathName,FilterIndex]=uigetfile or [FileName, ...
- QT 打开文件对话框汇总
Qstring fileName = QFileDialog::getOpenFileName(this, tr("open file"), " ", tr( ...
随机推荐
- Calendar类的一些不易区分的属性
1.Calendar.MONTH 月份从0-11,获取之后需要加1才能得到真正的月份 2.Calendar.DAY_OF_WEEK 本周的第几天,从星期天开始算 3.Calendar.WEEK_OF_ ...
- Python os、sys、pickle、json等模块
1.os 所有和操作系统相关的内容都在os模块,一般用来操作文件系统 import os os.makedirs('dirname1/dirname2') # 可生成多层递归目录 os.removed ...
- influxdb-1.7.2.x86_64安装 install influxdb-1.7.2.x86_64 on RedHat & CentOS
1.下载安装 wget http://dl.influxdata.com/influxdb/releases/influxdb-1.7.2.x86_64.rpm https://portal.infl ...
- jsonp 实现跨域
为什么会出现跨域问题 跨域的安全限制都是对浏览器端来说的,服务器端是不存在跨域安全限制的. 浏览器的同源策略限制从一个源加载的文档或脚本与来自另一个源的资源进行交互. 如果协议,端口和主机对于两个页面 ...
- CSS编辑元素的浮动
1.元素浮动: 1)使用 float:left; 这样的格式设置元素的浮动方式,属性值可以是left,right: 2)元素设置为左浮动时,元素将从原区域浮动到浏览器的左侧页面:右浮动时,就会附在右侧 ...
- C3p0 的一个异常
转的,异常如下: NewPooledConnection - com.mchange.v2.c3p0.impl.NewPooledConnection@1285252 closed by a clie ...
- 2018-10-16 22:56:13 c language
2018-10-16 22:56:13 c language 我们把上面的步骤总结一下,可以发现一个完整的编程过程是: 编写源文件:这是编程的主要工作,我们要保证代码的语法 100% 正确,不能有任何 ...
- 解决ci框架php发送邮件附件中文乱码问题
CI框架发送邮件附件中文出现乱码,是因为php basename()函数不支持中文引起,修改类库 Email.php 文件中 _append_attachments()方法,大致在 1474行 添加如 ...
- LeetCode题解之 Continuous Subarray Sum
1.题目描述 2.循环计算即可 3.代码 bool checkSubarraySum(vector<int>& nums, int k) { ){ return false ; } ...
- MATLAB中批量导入.mat文件(每个文件多变量)
一.新建MATLAB script(.m文件):readall_mat.m 二.代码如下: function data = readall_mat(path) % READALL_MAT 读取所有文件 ...