QMessageBox

QMessageBox msgBox; //定义一个消息框

msgBox.setText("the document ........"); //内容

msgBox.exec(); //等待某事件发生 并处理。。。。。。。

A better approach than just alerting the user to an event is to also ask the user what to do about it. Store the question in the informative text property, and set the standard buttons property to the set of buttons you want as the set of user responses. The buttons are specified by combining values from StandardButtonsusing the bitwise OR operator. The display order for the buttons is platform-dependent.

 

QMessageBox msgBox;

msgBox.setWindowTitle("message");

msgBox.setText("aaaaa");

msgBox.setInformativeText("do you want to save your changes");

msgBox.setStandarButtons(QMessageBox::Save|QMessageBox::Cancel);

msgBox.setDefaultButton(QMessageBox::Save);

int ret=msgBox.exec();

switch(ret)

{

            case QMessageBox::Save:

            

              break;

 

 

}

 

消息框可以根据你所做的选择(点击的按钮),来回应相应的东动作。这样有利于我们对事件的处理。

为了提供更详细的信息来帮助用户做选择,QMessageBox还提供了 detailed text(详细文本)功能。

 

当点击detailed,则show detailedtext。

 

QMessageBox没有信号和槽

 

 

 

 

 一个按钮可以和QMessageBox::Default标记进行或运算,这使得它成为默认按钮(当Enter被按下时,它被点击)。

 

如若想要显示更详细的的提示信息。可以使用此函数 

void setDetailedText(const QString &text);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值