Qt6基于Qml的文件对话框演示效果
更新时间:2022年10月14日 15:10:09 作者:江鸟木又
这篇文章主要介绍了Qt6基于Qml的文件对话框演示,包括打开单个文件配置和打开多个文件配置及保存文件配置的方法,本文通过实例代码给大家介绍的非常详细,需要的朋友可以参考下
主界面如下
打开单个文件配置
FileDialog { id: idFileOpenOne fileMode: FileDialog.OpenFile nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly }
打开多个文件配置
FileDialog { id: idFileOpenMore fileMode: FileDialog.OpenFiles nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly }
保存文件配置
FileDialog { id: idFileSave nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] fileMode: FileDialog.SaveFile }
三个按钮布局
Row{ anchors.centerIn: parent spacing: 30 Button{ text: qsTr("Open") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenOne.open(); } } } Button{ text: qsTr("Open More ...") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenMore.open(); } } } Button{ text: qsTr("Save") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileSave.open(); } } } }
点击效果展示:
完整源码:
import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import Qt.labs.platform 1.1 ApplicationWindow { visible: true width: 600 height: 200 title: qsTr("Qt6基于Qml的文件对话框演示") Row{ anchors.centerIn: parent spacing: 30 Button{ text: qsTr("Open") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenOne.open(); } } } Button{ text: qsTr("Open More ...") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenMore.open(); } } } Button{ text: qsTr("Save") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileSave.open(); } } } } FileDialog { id: idFileOpenOne fileMode: FileDialog.OpenFile nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly } FileDialog { id: idFileOpenMore fileMode: FileDialog.OpenFiles nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly } FileDialog { id: idFileSave nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] fileMode: FileDialog.SaveFile } }
到此这篇关于Qt6基于Qml的文件对话框演示的文章就介绍到这了,更多相关Qml文件对话框内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
详解addEventListener的三个参数之useCapture
本文主要给大家介绍的是addEventListener的三个参数之中的useCapture参数的使用及示例分享,有需要的小伙伴参考下2015-03-03当自定义数据属性为json格式字符串时jQuery的data api问题探讨
当自定义数据属性是一个 json 格式字符串时,缓存的数据如果被修改, 则修改后的数据继续存在于缓存系统中, 如果不留意,这可能导致一些BUG,接下来将对此问题详细概述下2013-02-02Bootstrap导航菜单点击后无法自动添加active的处理方法
今天小编就为大家分享一篇Bootstrap导航菜单点击后无法自动添加active的处理方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-08-08
最新评论