zoukankan      html  css  js  c++  java
  • (六)QDialog,QMessageBox,QFileDialog,QColorDialog颜色,QFontDialog字体

    QDialog

    对话框:

    1.模态对话框

    QDialog dlg(this);
     // 显示模态对话框 exec ,后面的不可操作
    dlg.exec(); // 阻塞

    2.非模态对话框

    QDialog *dlg = new QDialog(this);
    // 显示非模态对话框 show()
    // 设置对话框属性
    dlg->setAttribute(Qt::WA_DeleteOnClose);
    dlg->show(); // 非阻塞

    QMessageBox

    Static Public Members:question,information,warnnig,....

        connect(ui->actionOpen, &QAction::triggered, this, [=]()
        {
            if(QMessageBox::Ok == QMessageBox::question(this, "error", "系统文件错误!!!",
                                                       QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
            {
               QDialog dlg(this);
                // 显示模态对话框 exec
               dlg.exec(); // 阻塞
    
           }
    
        });

    QFileDialog

        connect(ui->actionOpen, &QAction::triggered, this, [=]()
        {
            QString name = QFileDialog::getOpenFileName(this, "打开文件", "D:\", "Image (*.jpg *.png)");
            qDebug() << name.toUtf8().data();
    
        });

    QColorDialog

            QColor color = QColorDialog::getColor();
            qDebug() << color.red() << color.green() << color.blue();

    QFontDialog

            bool ok;
            QFont font = QFontDialog::getFont(&ok, QFont("华文彩云"), this, "我的字体设置");
            if(ok)
            {
                qDebug() << font.family().toUtf8().data() << font.italic() << font.pointSize() << font.bold();
            }

  • 相关阅读:
    mustcache 模板语法
    java 打印pdf文件
    java从远程服务器获取PDF文件并后台打印(使用pdfFox)
    如何写md格式的文档
    mysql游标的用法及作用
    Spring
    JQuery.extend扩展实现同步post请求
    tp5框架的获取器
    ThinkPHP开启设置子域名笔记
    每天进步一点点
  • 原文地址:https://www.cnblogs.com/xiangtingshen/p/10749323.html
Copyright © 2011-2022 走看看