Qt入门-提示、警告、错误、询问、关于对话框
来源:互联网 发布:淘宝网店上架宝贝 编辑:程序博客网 时间:2024/06/08 12:06
QMessageBox类提供了常用的弹出式对话框:提示、警告、错误、询问、关于对话框
原型如下:
- void about ( QWidget * parent, const QString & title, const QString & text )
- void aboutQt ( QWidget * parent, const QString & title = QString() )
- StandardButton critical ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )
- StandardButton information ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )
- StandardButton question ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )
- StandardButton warning ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )
(1)title表示标题
(2)text是对话框中的内容信息
(3)buttons是要显示的按钮,它可以是:
- NoButton = 0x00000000,
- Ok = 0x00000400,
- Save = 0x00000800,
- SaveAll = 0x00001000,
- Open = 0x00002000,
- Yes = 0x00004000,
- YesToAll = 0x00008000,
- No = 0x00010000,
- NoToAll = 0x00020000,
- Abort = 0x00040000,
- Retry = 0x00080000,
- Ignore = 0x00100000,
- Close = 0x00200000,
- Cancel = 0x00400000,
- Discard = 0x00800000,
- Help = 0x01000000,
- Apply = 0x02000000,
- Reset = 0x04000000,
- RestoreDefaults = 0x08000000,
(4)defaultButton是默认激活的按钮
(5)对话框的返回值即是用户最终点击的按钮。
示例:
- 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, 0, 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"));
- }
界面:
0 0
- Qt入门-提示、警告、错误、询问、关于对话框
- Qt入门-提示、警告、错误、询问、关于对话框
- 提示、警告、错误、询问、关于对话框
- QT5入门之6 - Qt提示对话框
- easyui 提示,警告,错误
- 关于vs提示:警告被视为错误的解决方法
- 询问对话框
- 关于Qt的一个错误提示
- QT关于iCCP警告
- Qt进度条提示对话框
- iOS开发从入门到精通-- 警告对话框UIAlertView和等待提示器UIActivityIndicatorView
- [转]DELPHI警告错误提示
- Keil 【警告+错误】提示汇总
- bootstrap错误警告信息提示
- 关于记事本[另存为]时,提示“共用对话框错误”的问题
- RadControl后台弹出窗口,对话框,警告提示。
- Qt入门(对话框)
- 关于定时关闭询问对话框的一点体会
- html中常用单位
- 对于自学验证码识别的感想
- 南昌大学软院大神养成计划----第三天编写简易网页
- 【MySQL进阶】--char & varchar & text的区别
- Flume + HDFS Sink采集数据及如何添加第三方JAR
- Qt入门-提示、警告、错误、询问、关于对话框
- python_2
- 集合框架(增加,删除,判断元素以及迭代器)
- java序列化与反序列化
- 银联支付-手机网页支付接口开发
- Oracle 自定义结构(Record) 记录
- UI_容器视图控制器
- 数据库之 触发器 基础
- 对matlab中colormap的解释及fill、imshow的用法说明