QT的常用对话框的应用
生活随笔
收集整理的這篇文章主要介紹了
QT的常用对话框的应用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
QMessageBox類提供了常用的彈出式對話框:提示、警告、錯誤、詢問、關于對話框
需要添加頭文件?
#include <QMessageBox>MESSAGE? 是要是顯示的字符串
void Dialog::criticalMessage() { QMessageBox::StandardButton reply; reply = QMessageBox::critical(this, tr("QMessageBox::critical()"), MESSAGE, QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore); if (reply == QMessageBox::Abort) criticalLabel->setText(tr("Abort")); else if (reply == QMessageBox::Retry) criticalLabel->setText(tr("Retry")); else criticalLabel->setText(tr("Ignore")); } void Dialog::informationMessage() { QMessageBox::StandardButton reply; reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE); if (reply == QMessageBox::Ok) informationLabel->setText(tr("OK")); else informationLabel->setText(tr("Escape")); } void Dialog::questionMessage() { QMessageBox::StandardButton reply; reply = QMessageBox::question(this, tr("QMessageBox::question()"), MESSAGE, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if (reply == QMessageBox::Yes) questionLabel->setText(tr("Yes")); else if (reply == QMessageBox::No) questionLabel->setText(tr("No")); else questionLabel->setText(tr("Cancel")); } void Dialog::warningMessage() { QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), MESSAGE, 0, this); msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole); msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) warningLabel->setText(tr("Save Again")); else warningLabel->setText(tr("Continue")); }?
轉載于:https://www.cnblogs.com/wanghuixi/p/7000764.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的QT的常用对话框的应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git branch 为什么会进入编辑状
- 下一篇: qt5 交叉编译webkit_基于QT平