QMessageBox

常用的消息对话框包括Question消息框,Information消息框,Warning消息框
Critical消息框,About消息框,AboutQt消息框和Custom自定义消息框。
Question消息框
使用QMessageBox::question函数完成
StandardButton QMessageBox::question
{
QWidget* paretn,
const QString*&title,
const QString &text,
StandardButtons buttons=ok,//填写希望在消息框中出现的按钮,用|连写,默认为QMessage::Ok.
StandardButton defaultButton=NoButton//消息框出现时,焦点默认在哪个按钮上
);

void MsgBoxDlg::showQuestionMsg()
{
label->setText(tr("Question Message Box"));
switch(QMessageBox::question(this,tr("Question消息框"),tr("是否结束程序"),QMessgaeBox::OK|QMessageBox::Cancel,QMessageBox::OK))
{
case QMessageBox::OK:
label->setText("Question button/OK");
break;
case QMessageBox::Cancel:
label->setText("Qusetion button/Cancel");
break;
default:
break;
}
return;
}

Information消息框
StandardButton QMessageBox::information
(
QWidget *parent,
const QString& title,
const QString &text,
StandardButtons buttons=OK,
StandardButton defaultButton=NoButton
);

Warning消息框
Warning消息框使用QMessageBox::warning()函数,和Information函数,question函数类似。
Critical消息框
使用QMessageBox::critical()函数
About消息框
使用QMessageBox::about()函数
AboutQt消息框
使用QMessageBox::aboutQt()函数

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值