QMessageBox 的四种用法
void MainWindow::on_info_clicked()
{
//info
QMessageBox::information(this, "Title", "Text");
} void MainWindow::on_question_clicked()
{
//question
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Title", "Do you like cat?", QMessageBox::Yes | QMessageBox::No);
if(reply == QMessageBox::Yes)
{
}
else
{
}
} void MainWindow::on_warning_clicked()
{
//warning
QMessageBox::warning(this, "Title", "Text");
} void MainWindow::on_pushButton_4_clicked()
{
QMessageBox::question(this, "Title", "Do you like cat?", QMessageBox::YesToAll|QMessageBox::Yes|QMessageBox::No);
} class MyMessageBox : public QObject
{
public:
MyMessageBox();~MyMessageBox(); static void ChMessageOnlyOk_Information(QString info)
{
QMessageBox msg;
msg.setWindowTitle(tr("提示"));
msg.setText(info);
msg.setStyleSheet("font: 14pt;background-color:rgb( 0,220, 0)");
msg.setIcon(QMessageBox::Information);
msg.addButton(tr("确定"),QMessageBox::ActionRole);
msg.exec();
} static void ChMessageOnlyOk_Error(QString info)
{
QMessageBox msg;
msg.setWindowTitle(tr("提示"));
msg.setText(info);
msg.setStyleSheet("font: 14pt;background-color:rgb(220, 0, 0)");
msg.setIcon(QMessageBox::Critical);
msg.addButton(tr("确定"),QMessageBox::ActionRole);
msg.exec();
} static int ChMessageOkCancel(QString info)
{
QMessageBox msg;
msg.setWindowTitle(tr("提示"));
msg.setText(info);
msg.setStyleSheet("color:rgb(220, 0, 0);font: 14pt");
msg.setIcon(QMessageBox::Information);
msg.addButton(tr("确定"),QMessageBox::ActionRole);
msg.addButton(tr("取消"),QMessageBox::ActionRole);
return msg.exec();
}
}; int ret = MyMessageBox::ChMessageOkCancel(tr("是否继续?"));
if( == ret)
{ }
else if( == ret)
{
}
---------------------
作者:阳光柠檬_
来源:CSDN
原文:https://blog.csdn.net/liukang325/article/details/13768481
版权声明:本文为博主原创文章,转载请附上博文链接!
QMessageBox 的四种用法的更多相关文章
- mysql中模糊查询的四种用法介绍
下面介绍mysql中模糊查询的四种用法: 1,%:表示任意0个或多个字符.可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分号(%%)表示. 比如 SELECT * FROM [user] ...
- mysql进阶(六)模糊查询的四种用法介绍
mysql中模糊查询的四种用法介绍 这篇文章主要介绍了mysql中模糊查询的四种用法,需要的朋友可以参考下. 下面介绍mysql中模糊查询的四种用法: 1 %: 表示任意0个或多个字符.可匹配任意类型 ...
- 【转载】java static 关键字的四种用法
原文链接点这里,感谢博主分享 在java的关键字中,static和final是两个我们必须掌握的关键字.不同于其他关键字,他们都有多种用法,而且在一定环境下使用,可以提高程序的运行性能,优化程序的结构 ...
- [java]static关键字的四种用法
在java的关键字中,static和final是两个我们必须掌握的关键字.不同于其他关键字,他们都有多种用法,而且在一定环境下使用,可以提高程序的运行性能,优化程序的结构.下面我们先来了解一下stat ...
- c++中for的四种用法
#include <algorithm> #include <vector> #include <iostream> using namespace std; in ...
- C#中 this关键字 四种用法
/// <summary> /// 主程序入口 /// </summary> /// <param name="args"></param ...
- 下面介绍mysql中模糊查询的四种用法:
下面介绍mysql中模糊查询的四种用法: 1,%:表示任意0个或多个字符.可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分号(%%)表示. 比如 SELECT * FROM [user] ...
- javascript中this的四种用法
javascript中this的四种用法 投稿:hebedich 字体:[增加 减小] 类型:转载 时间:2015-05-11我要评论 在javascript当中每一个function都是一个对象,所 ...
- this的四种用法!
经常会有人问到this的用法,其实简单来说,this有四种应用场景,分别是在构造函数上.对象属性中.普通函数中.call和apply方法中. 首先我们来看第一种:在构造函数中的用法 第二种是在在对象属 ...
随机推荐
- Python3之Zip
from collections import defaultdict from collections import OrderedDict d = defaultdict(list) d['a'] ...
- ProE复杂曲线方程:Python Matplotlib 版本代码(L系统,吸引子和分形)
对生长自动机的研究由来已久,并在计算机科学等众多学科中,使用元胞自动机的概念,用于生长模拟.而复杂花纹的生成,则可以通过重写一定的生长规则,使用生成式来模拟自然纹理.当然,很多纹理是由人本身设计的,其 ...
- demo记录
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http ...
- php第十八节课
PDO 对不同的数据库连接使用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "ht ...
- nexus3的安装和使用
参考:https://www.cnblogs.com/2YSP/p/9533506.html http://www.54tianzhisheng.cn/2017/10/14/Nexus3-Maven/ ...
- Problem 29
Problem 29 Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 仔细看看以下a与b的组合 22=4, 2 ...
- PAT 1107 Social Clusters
When register on a social network, you are always asked to specify your hobbies in order to find som ...
- BZOJ 4278 [ONTAK2015]Tasowanie (后缀数组)
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=4278 题解: 居然把后缀数组写成n^2的..我真厉害.. 想了无数种方法,最后发现就是 ...
- 【郑轻邀请赛 A】tmk射气球
[题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2127 [题意] [题解] 把气球和飞艇所代表的直线投影到xoy面上 设气球所在位置为 ...
- Codeforces Round #417 (Div. 2)——ABCE
题目链接 题面有点长需耐心读题. A.一个人行道上的人被撞有4种情况 1.所在车道有车驶出 2.右边车道有左转车 3.左边车道有右转车 4.对面车道有直行车 #include <bits/std ...