- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
4.5.1 Question消息框 完成文件msgboxdlg.cpp中的槽函数showQuestionMsg()的具体代码如下: void MsgBoxDlg::showQuestionMsg() { label-setText(tr(Question Message Box)); switch(QMessageBox::question(this,tr(Question消息框), tr(您现在已经修改完成,是否要结束程序?), QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Ok)) { case QMessageBox::Ok: label-setText(Question button/Ok); break; case QMessageBox::Cancel: label-setText(Question button/Cancel); break; default: break; } return; } 在msgboxdlg.cpp的开头添加头文件: #includeQMessageBox 4.5.2 Information消息框 Information消息框使用QMessageBox::information()函数完成,函数形式如下: StandardButton QMessageBox::information ( QWidget*parent, //消息框的父窗口指针 const QString title, //消息框的标题栏 const QString text, //消息框的文字提示信息 StandardButtons buttons=Ok, //同上Question消息框的注释内容 StandardButton defaultButton=NoButton //同上Question消息框的注释内容 ); 完成文件msgboxdlg.cpp中的槽函数showInformationMsg(),具体实现如下: void MsgBoxDlg::showInformationMsg() { label-setText(tr(Information Message Box)); QMessageBox::information(this,tr(Information消息框), tr(这是Information消息框测试,欢迎您!)); return; } 4.5.3 Warning消息框 Warning消息框使用QMessageBox::warning()函数完成,函数形式如下: StandardButton QMessageBox::warning ( QWidget* parent, //消息框的父窗口指针 const QString title, //消息框的标题栏 const QString text, //消息框的文字提示信息 StandardButtons buttons=Ok, //同上Question消息框的注释内容 StandardButton defaultButton=NoButton //同上Question消息框的注释内容 ); Warning消息框 完成文件msgboxdlg.cpp中的槽函数showWarningMsg(),具体实现如下: void MsgBoxDlg::showWarningMsg() { label-setText(tr(Warning Message Box)); switch(QMessageBox::warning(this,tr(Warning消息框), tr(您修改的内容还未保存,是否要保存对文档的修改?), QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel, QMessageBox::Save)) { case QMessageBox::Save: label-setText(tr(Warning
文档评论(0)