现在的位置: 首页 > 综合 > 正文

QMessageBox

2013年03月06日 ⁄ 综合 ⁄ 共 1165字 ⁄ 字号 评论关闭

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);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

抱歉!评论已关闭.