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( ...
随机推荐
- sql连接查询(inner join、full join、left join、 right join)
sql连接查询(inner join.full join.left join. right join) 一.内连接(inner join) 首先我这有两张表 1.顾客信息表customer 2.消费订 ...
- 一些减少代码量、提高开发效率的利器(Java)
Spring Boot mybatis-plus代码生成器和自带CRUD接口 lombok 库: Apache Commons & guava AOP Java8: stream & ...
- python移位运算符
1,二进制方式 >>> bin( 1 ) '0b1' >>> bin( 10 ) '0b1010' >>> a = 0b10 >>&g ...
- 页面中多个script块之间方法与变量共享问题
JS是按照代码块来进行编译和执行的,代码块间相互独立,但变量和方法共享,按顺序执行. 如: <script type='text/javascript'> var m = 0,n = 1, ...
- 【代码笔记】iOS-在导航栏中显示等待对话框
一,效果图. 二,代码. ViewController.m #import "ViewController.h" @interface ViewController () @end ...
- JS中String与Array的一些常用方法
真是恨透了这些类似于substring substr slice 要么长得像,要么就功能相近的方法... 1⃣️string 1.substring(start开始位置的索引,end结束位置索引) 截 ...
- Python 基于Python实现邮件发送
基于Python实现邮件发送 by:授客 QQ:1033553122 测试环境: Python版本:Python 2.7 注:需要修改mimetypes.py文件(该文件可通过文章底部的网盘分 ...
- node socket :10106无法加载或初始化请求的服务提供程序
node socket :10106无法加载或初始化请求的服务提供程序 无端端的,不知道怎么回事,node突然就坏掉 了,应该是某些配置无意中改动了,问题如下: 目前能想到的解决办法就是:重置配置,用 ...
- Windows10系统的Linux子系统中安装MySQL数据库心得
后端开发童鞋们, 自己开发机用的是Windows系统电脑(台式机或笔记本), 而开发的程序和使用的数据库等要运行在Linux服务器上, 这种情况有木有? 提前声明: 本文并不讨论操作系统的比较, 以及 ...
- java web dev知识积累
tomcat体系结构 可以从tomcat的server.xml文件中元素的层次结构来理解tomcat的体系结构: Server(可以视为tomcat本身)->经由connector可以有多个(c ...