import QtQuick 2.14
import QtQuick.Controls 2.14
import Qt.labs.platform 1.0
ApplicationWindow {
visible: true
width: 800
height: 600
title: qsTr("选择文件夹对话框")
Rectangle {
id: inputBox
width: 350
height: 40
color: "#F3F6FA"
clip: true
border.width: 1
border.color: "#DFE0E4"
radius: 5
anchors.centerIn: parent
TextInput {
id: inputBoxInput
text:folderDialog.folder
color: "#707070"
font.pixelSize: 16
activeFocusOnTab: true
selectByMouse: true //是否可以选择文本
selectedTextColor: "white" //设置选择文本的字体颜色
selectionColor: "#4A6DBC" //设置选择框的颜色
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignLeft
anchors.fill: parent
leftPadding: 3
rightPadding: 3
}
}
Button{
text: qsTr("选择路径")
height: 40
width: 120
anchors{
verticalCenter: inputBox.verticalCenter
left: inputBox.right
leftMargin: 20
}
MouseArea{
anchors.fill: parent
onClicked: {
folderDialog.open()
}
}
}
FolderDialog {
id: folderDialog
folder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] //默认打开Pictures文件夹
}
}
QML 打开文件夹对话框选择文件保存路径
最新推荐文章于 2024-07-19 17:29:59 发布