QML 打开文件夹对话框选择文件保存路径

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文件夹
    }
}

  • 6
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值