QML中的消息弹窗和文件弹窗

import QtQuick
import QtQuick.Controls.Material    //Material要放在Dialogs的前面,否则会报错
import QtQuick.Controls
import QtQuick.Dialogs

Window {
    id: root
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Column
    {
        padding: 20; spacing: 20

        Button
        {
            text: "MessageDialog"

            onClicked: dlg.open()
        }

        Button
        {
            text: "FileDialog"
            onClicked:
            {
                fileDlg.open()
            }
        }
    }

    FileDialog
    {
        id: fileDlg
        
        fileMode: FileDialog.OpenFile   //枚举,FileDialog.OpenFile、FileDialog.OpenFiles、FileDialog.SaveFile
        
        acceptLabel: "acceptLabel"  //替换掉系统文件窗口下的“打开(O)”的按钮的文本
        rejectLabel: "rejectLabel"  //替换掉系统文件窗口下的“取消”的按钮的文本

        onAccepted:
        {
            dlg.text = selectedFile
            dlg.open()
        }
    }

    MessageDialog
    {
        id: dlg

        title: "MessageDialog"
        text: "This is a MessageDialog."

        buttons: MessageDialog.SaveAll | MessageDialog.Cancel | MessageDialog.Ok | MessageDialog.Close

        onAccepted: print(text)
        onRejected: print("MessageDialog onRejected")
    }
}

 

相关推荐

  1. flutter 底部中间

    2024-07-19 22:26:02       55 阅读
  2. jswindowOPen方法,特征

    2024-07-19 22:26:02       47 阅读
  3. 小程序

    2024-07-19 22:26:02       55 阅读
  4. 鸿蒙:警告

    2024-07-19 22:26:02       55 阅读
  5. CSS<span style='color:red;'>弹</span><span style='color:red;'>窗</span>

    CSS

    2024-07-19 22:26:02      20 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 22:26:02       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 22:26:02       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 22:26:02       45 阅读
  4. Python语言-面向对象

    2024-07-19 22:26:02       55 阅读

热门阅读

  1. 每类数据保留前n条(sql)

    2024-07-19 22:26:02       13 阅读
  2. 慢查询&sql&索引优化

    2024-07-19 22:26:02       15 阅读
  3. [C/C++入门][ifelse]15、判断奇偶数

    2024-07-19 22:26:02       16 阅读
  4. 99:PostgreSQL开启SQL语句日志收集

    2024-07-19 22:26:02       18 阅读
  5. 数学黑洞6174

    2024-07-19 22:26:02       18 阅读
  6. 日文医学文献pdf怎么翻译

    2024-07-19 22:26:02       16 阅读
  7. 8.3 End-to-end Data Protection (Optional)

    2024-07-19 22:26:02       17 阅读