zoukankan      html  css  js  c++  java
  • QMessageBox 的四种用法

    void MainWindow::on_info_clicked()
    {
    //info
    QMessageBox::information(this, "Title", "Text");
    }
     
    void MainWindow::on_question_clicked()
    {
    //question
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Title", "Do you like cat?", QMessageBox::Yes | QMessageBox::No);
    if(reply == QMessageBox::Yes)
    {
    }
    else
    {
    }
    }
     
    void MainWindow::on_warning_clicked()
    {
    //warning
    QMessageBox::warning(this, "Title", "Text");
    }
     
    void MainWindow::on_pushButton_4_clicked()
    {
    QMessageBox::question(this, "Title", "Do you like cat?", QMessageBox::YesToAll|QMessageBox::Yes|QMessageBox::No);
    }
    
    
    
    
    
    class MyMessageBox : public QObject
    {
    public:
        MyMessageBox();~MyMessageBox();
     
        static void ChMessageOnlyOk_Information(QString info)
        {
            QMessageBox msg;
            msg.setWindowTitle(tr("提示"));
            msg.setText(info);
            msg.setStyleSheet("font: 14pt;background-color:rgb( 0,220, 0)");
            msg.setIcon(QMessageBox::Information);
            msg.addButton(tr("确定"),QMessageBox::ActionRole);
            msg.exec();
        }
     
        static void ChMessageOnlyOk_Error(QString info)
        {
            QMessageBox msg;
            msg.setWindowTitle(tr("提示"));
            msg.setText(info);
            msg.setStyleSheet("font: 14pt;background-color:rgb(220, 0, 0)");
            msg.setIcon(QMessageBox::Critical);
            msg.addButton(tr("确定"),QMessageBox::ActionRole);
            msg.exec();
        }
     
        static int ChMessageOkCancel(QString info)
        {
            QMessageBox msg;
            msg.setWindowTitle(tr("提示"));
            msg.setText(info);
            msg.setStyleSheet("color:rgb(220, 0, 0);font: 14pt");
            msg.setIcon(QMessageBox::Information);
            msg.addButton(tr("确定"),QMessageBox::ActionRole);
            msg.addButton(tr("取消"),QMessageBox::ActionRole);
            return msg.exec();
        }
    };
     
     
     
     
    int ret = MyMessageBox::ChMessageOkCancel(tr("是否继续?"));
    if(1 == ret)
    {
     
    }
    else if(0 == ret)
    {
    }

    ---------------------
    作者:阳光柠檬_
    来源:CSDN
    原文:https://blog.csdn.net/liukang325/article/details/13768481
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    webpack 5 之持久化缓存
    前端资源加载失败优化
    如何用 JS 实现二叉堆
    简单解析一下扫码登陆原理,简单到你想不到!
    实战:Express 模拟 CSRF 攻击
    Yarn 的 Plug'n'Play 特性
    为什么现在我更推荐 pnpm 而不是 npm/yarn?
    小米3移动版刷安卓6.0-小米手机3 移动版 Flyme 6.7.11.24R beta
    小米5手机最后一版安卓6.0 MIUI8 6.11.10 小米5s手机最后一版安卓6.0 MIUI8 7.6.8
    vim格式转换
  • 原文地址:https://www.cnblogs.com/findumars/p/9818455.html
Copyright © 2011-2022 走看看