FileDialog in QTQuick (QML): Save file under given name

折月煮酒 提交于 2019-12-05 03:30:44

This blog post covers the whole problem and provides a possible solution: Advanced FileDialog in QML (Save file under given name)

I hope this will be still helpful. I found a compromise that at least works for me. I used Qt.labs.platform 1.1 FileDialog QML Type: https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html

FileDialog {
            id: saveDialog
            property MyClass myObj
            title: "Save Dialog"
            folder: myObjHasAPath? myObj.path: "file:///" //Here you can set your default folder
            currentFile: "file:///"+myObj.name //The name of the item that you want to save
            fileMode: Platform.FileDialog.SaveFile
        }

Try setting the FileDialog selectExisting property to false.

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