码迷,mamicode.com
首页 > 其他好文 > 详细

QMessageBox 用法

时间:2016-06-11 00:34:37      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

案例一:
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
switch (ret)
{
case QMessageBox::Save:
// Save was clicked
break;
case QMessageBox::Discard:
// Don‘t Save was clicked
break;
case QMessageBox::Cancel:
// Cancel was clicked
break;
default:
// should never be reached
break;
}


案例二:
int ret = QMessageBox::warning(this,
tr("My Application"),
tr("The document has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save);


案例三:添加按钮、判断哪个按钮按下
QMessageBox msgBox;
QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
if(msgBox.clickedButton() == connectButton)
{
// connect
}
else if(msgBox.clickedButton() == abortButton)
{
// abort
}
msgBox.exec();

http://blog.csdn.net/jan5_reyn/article/details/38955705

QMessageBox 用法

标签:

原文地址:http://www.cnblogs.com/findumars/p/5574502.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!