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的常用对话框的应用的更多相关文章

  1. 第八章 Qt GUI之对话框使用

    第八章 Qt GUI之对话框使用 对话框可以是模态(modal)的或非模态(modeless)两种.当我们在一个用户界面程序里面对一个对话框(比如选择文件对话框)的操作没有结束前,界面的其他窗口无法操 ...

  2. QT学习 之 对话框 (四) 字体对话框、消息对话框、文件对话框、进程对话框(超详细中文注释)

    QMessageBox类: 含有Question消息框.Information消息框.Warning消息框和Critical消息框等 通常有两种方式可以来创建标准消息对话框: 一种是采用“基于属性”的 ...

  3. android常用对话框封装

    在android开发中,经常会用到对话框跟用户进行交互,方便用户可操作性:接下来就对常用对话框进行简单封装,避免在项目中出现冗余代码,加重后期项目的维护量:代码如有问题欢迎大家拍砖指正一起进步. 先贴 ...

  4. Android 常用对话框Dialog封装

    Android 6种 常用对话框Dialog封装 包括: 消息对话框.警示(含确认.取消)对话框.单选对话框. 复选对话框.列表对话框.自定义视图(含确认.取消)对话框 分别如下图所示:       ...

  5. Qt creator 常用的快捷健

    Qt creator 常用的快捷健 F1        查看帮助F2        跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2    声明和定义之间切换F4        头文件 ...

  6. matlab GUI之常用对话框(四)-- 输入对话框 inputdlg、目录对话框 uigetdir、列表对话框 listdlg

    常用对话框(四) 1.输入对话框  inputdlg answer = inputdlg(prompt) answer = inputdlg(prompt,dlg_title) answer = in ...

  7. matlab GUI之常用对话框(二)-- 进度条的使用方法

    常用对话框(二) 进度条   waitbar 调用格式: h = waitbar(x,'message')  waitbar(x,'message','CreateCancelBtn','button ...

  8. matlab GUI之常用对话框(一)-- uigetfile\ uiputfile \ uisetcolor \ uisetfont

    常用对话框(一) 1.uigetfile  文件打开对话框 调用格式:      [FileName,PathName,FilterIndex]=uigetfile or     [FileName, ...

  9. QT 打开文件对话框汇总

    Qstring fileName = QFileDialog::getOpenFileName(this, tr("open file"), " ",  tr( ...

随机推荐

  1. django 参考

    1. 路由系统 https://www.cnblogs.com/maple-shaw/articles/9282718.html 2. 视图 https://www.cnblogs.com/maple ...

  2. C# HmacSha512 与 java HmacSha512 加密

    C# HmacSha512 与 java HmacSha512 加密. /// <summary> /// HmacSha512 加密 /// </summary> /// & ...

  3. mysql小试题3

    查询结果:

  4. Code Signal_练习题_Knapsack Light

    You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...

  5. 微信小程序传参数的几种方法

    1,navigator 跳转时 wxml页面(参数多时可用“&”) <navigator url='../index/index?id=1&name=aaa'></n ...

  6. 说说对npm的开发模式和生产模式的理解

    nodejs这些年的发展非常快,相信没有哪个前端不知道的了,npm也成为了前端开发中经常用到了的一个命令.那么npm不是只用一个 "npm install xxx"命令就够了吗?实 ...

  7. idea 提交 Push rejected: Push to origin/master was rejected

    idea中,发布项目到码云上,当时按照这样的流程添加Git,然后push,提示:push to origin/master war rejected". 解决方案如下: 1.切换到自己项目所 ...

  8. JavaSE——线程通信

    线程通信: 如果线程A和线程B持有同一个MyObject类的对象object,这两个线程会去调用不同的方法,但是它们是同步执行的,比如:线程B需要等待线程A执行完了methodA()方法之后,它才能执 ...

  9. 稳聘App设计图分享

    摘要||潜心学习,无限开源,我是鸟窝,一只憨厚的鸟,联系我加微信:jkxx123321 很早期就想筹划上线一款招聘类App,一拖再拖,先做还没有上线. 下面的设计原图,为我UI徒弟所做,在此,表示万分 ...

  10. 分享一个android debug模式,出现 waiting for debugger把界面卡住,取巧的解决办法

    使用android studio开发程序时,有时会出现 waiting for debugger 卡住界面,软件无法正常debug运行的情况,很多网友分享了一些解决办法,比如: 1 打开cmd进入命令 ...