Qt's FileDialog defaultSuffix not functionning

孤人 提交于 2019-12-11 02:32:24

问题


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
}
}

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


回答1:


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.



来源:https://stackoverflow.com/questions/48253836/qts-filedialog-defaultsuffix-not-functionning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!