qt MessageBOX 消息
void MessageBox::slotQuestion()
{
switch(QMessageBox::question(this,"Question",tr("It's end of document,search from begin?"),
QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Ok))
{
case QMessageBox::Ok:
label->setText(" Question button / Ok ");
break;
case QMessageBox::Cancel:
label->setText(" Question button / Cancel ");
break;
default:
break;
}
return;
} void MessageBox::slotInformation()
{
QMessageBox::information(this,"Information",tr("anything you want tell user"));
return;
} void MessageBox::slotWarning()
{
switch(QMessageBox::warning(this,"Warning",tr("Save changes to document?"),
QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel,QMessageBox::Save))
{
case QMessageBox::Save:
label->setText(" Warning button / Save ");
break;
case QMessageBox::Discard:
label->setText(" Warning button / Discard ");
break;
case QMessageBox::Cancel:
label->setText(" Warning button / Cancel ");
break;
default:
break;
}
return; } void MessageBox::slotCritical()
{
QMessageBox::critical(this,"Critical",tr("tell user a critical error"));
label->setText(" Critical MessageBox ");
return;
} void MessageBox::slotAbout()
{
QMessageBox::about(this,"About",tr("Message box example!"));
label->setText(" About MessageBox ");
return;
} void MessageBox::slotAboutQt()
{
QMessageBox::aboutQt(this,"About Qt");
label->setText(" About Qt MessageBox ");
return;
} void MessageBox::slotCustom()
{
QMessageBox customMsgBox;
customMsgBox.setWindowTitle("Custom message box");
QPushButton *lockButton = customMsgBox.addButton(tr("Lock"),QMessageBox::ActionRole);
QPushButton *unlockButton = customMsgBox.addButton(tr("Unlock"),QMessageBox::ActionRole);
QPushButton *cancelButton = customMsgBox.addButton(QMessageBox::Cancel);
customMsgBox.setIconPixmap(QPixmap(":/images/linuxredhat.png"));
customMsgBox.setText(tr("This is a custom message box"));
customMsgBox.exec(); if(customMsgBox.clickedButton() == lockButton)
label->setText(" Custom MessageBox / Lock ");
if(customMsgBox.clickedButton() == unlockButton)
label->setText(" Custom MessageBox / Unlock ");
if(customMsgBox.clickedButton() == cancelButton)
label->setText(" Custom MessageBox / Cancel "); return;
}
main.cpp
#include "messagebox.h"
#include <QtGui/QApplication> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MessageBox *w=new MessageBox;
w->show();
return a.exec();
}
效果图:






qt MessageBOX 消息的更多相关文章
- paip.c++ qt messagebox用法
paip.c++ qt messagebox用法 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net ...
- C# MessageBox 消息对话框
在程序中,我们经常使用消息对话框给用户一定的信息提示,如在操作过程中遇到错误或程序异常,经常会使用这种方式给用于以提示.在C#中,MessageBox消息对话框位于System.Windows.For ...
- C#中的MessageBox消息对话框
关键字:C# MessageBox 消息对话框 在程序中,我们经常使用消息对话框给用户一定的信息提示,如在操作过程中遇到错误或程序异常,经常会使用这种方式给用于以提示.在C#中,MessageBox消 ...
- WPF 实现带蒙版的 MessageBox 消息提示框
WPF 实现带蒙版的 MessageBox 消息提示框 WPF 实现带蒙版的 MessageBox 消息提示框 作者:WPFDevelopersOrg 原文链接: https://github.com ...
- Ext.MessageBox消息框
Ext JS消息提示框主要包括:alert.confirm.prompt.show 1.Ext.MessageBox.alert() 调用格式: alert( String title, String ...
- [转载]ExtJs4 笔记(6) Ext.MessageBox 消息对话框
作者:李盼(Lipan) 出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法 ...
- ExtJs4 笔记(6) Ext.MessageBox 消息对话框
本篇演示消息对话框的用法,ExtJs封装了可能用到的各类消息框,并支持自定义的配置. 如下是用到的html: [html] <h1>各种消息框</h1> <div id= ...
- windows程序设计 MessageBox消息框
MessageBox函数 int WINAPI MessageBoxW( HWND hWnd,//窗口句柄 LPCWSTR lpText,//消息框主体显示的字符串 LPCWSTR lpCaption ...
- 【转】QT CEF3 消息循环处理
初次写博客,可能有点乱, 按照自己的实际经历谈一下CEF3钟遇到的一些坑,希望对以后的小伙有些帮助. 先说一下经历,当初第一次接触CEF3的时候,没做特殊处理,直接将cef3封装成控件,嵌入到QT程序 ...
随机推荐
- 矩阵&&高斯消元
矩阵运算: \(A\times B\)叫做\(A\)左乘\(B\),或者\(B\)右乘\(A\). 行列式性质: \(1.\)交换矩阵的两行(列),行列式取相反数. \(2.\)某一行元素都\(\ti ...
- C语言字符串的操作
C语言字符串操作函数 1. 字符串反转 - strRev2. 字符串复制 - strcpy3. 字符串转化为整数 - atoi4. 字符串求长 - strlen5. 字符串连接 - strcat6. ...
- Java - n的阶乘计算
用递归方法,求10!的阶乘 分析: f(n) = n * f(n-1) n != 1 ----- 递推公式 f(n) = 1 ...
- LCA(最近公共祖先)
学习链接:https://baike.baidu.com/item/%E4%BC%B8%E5%B1%95%E6%A0%91/7003945?fr=aladdin 求LCA的方法有很多,在这里就只介绍一 ...
- SPRING中的线程池ThreadPoolTaskExecutor(转)
转自:https://blog.csdn.net/zhanglongfei_test/article/details/51888433 一.初始化 1,直接调用 ThreadPoolTaskExecu ...
- asp.net WebService技术简介
1.什么是web service? 这里借助百度百科专业的解释:web service是一个平台独立的.低耦合的.自包含的.基于可编程的web应用程序(说简单点,就是使用web service继续不需 ...
- vi 中插入当前时间
声明 笔者最近意外的发现 笔者的个人网站http://tiankonguse.com/ 的很多文章被其它网站转载,但是转载时未声明文章来源或参考自 http://tiankonguse.com/ 网站 ...
- window 端口占用,杀进程
假如我们需要确定谁占用了我们的8008端口,在windows命令行窗口下执行: C:\Documents and Settings>netstat -aon|findstr 80 看到了吗,端口 ...
- Spark中自定义累加器Accumulator
1. 自定义累加器 自定义累加器需要继承AccumulatorParam,实现addInPlace和zero方法. 例1:实现Long类型的累加器 object LongAccumulatorPara ...
- Mac OS X安装OpenGL
Mac OS X安装OpenGL 安装最新的cmake brew install cmake brew upgrade cmake 安装glew brew install glew 安装GLTools ...