Qt's FileDialog defaultSuffix not functionning

2019-07-09 05:06发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-09 05:30

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.

查看更多
登录 后发表回答