Qt的FileDialog defaultSuffix不起作用 [英] Qt's FileDialog defaultSuffix not functionning

查看:258
本文介绍了Qt的FileDialog defaultSuffix不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将以下代码用于QtQuick.Dialogs 1.3&中的filedialog的新属性. Qt 5.10.0.我已经使用Qt Creator 5.10默认工具包对其进行了构建.

I'm using the following code to the new property of the filedialog under QtQuick.Dialogs 1.3 & Qt 5.10.0. I've build it using Qt Creator 5.10 default kit.

import QtQuick 2.10
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.3

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


FileDialog {
    id: fileDialog
    title: "Please choose a file"
    folder: shortcuts.home
    defaultSuffix: "txt"
    selectExisting: false
    selectMultiple: false
    onAccepted: {
        console.log("You chose: " + fileUrl)
        Qt.quit()
    }
    onRejected: {
        console.log("Canceled")
        Qt.quit()
    }
    Component.onCompleted: visible = true
}
}

我的期望是,如果我选择文件名(例如"MyFile"),则fileUrl将是"MyFile.txt".但是,它只返回"MyFile".

My expectation are that if I choose a filename such as "MyFile", then the fileUrl would be "MyFile.txt". However it just returns "MyFile".

推荐答案

我已经测试了代码,但它的确带有".txt".我不确定这个问题,但是由于没有真正的问题,您可以使用

I have tested the code and it comes does come out with the ".txt". I am unsure of the problem but since there isn't really a question, you could append the default suffix using a global property.

这篇关于Qt的FileDialog defaultSuffix不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆