Important: Please read the Qt Code of Conduct -

Save file - set preset file name in QML FileDialog? (Windows)

  • Hello,

    I would like to set a preferred file name in a "Save file"-dialog. Like this:

    How to do this in for example QML FileDialog?
    I found some things:
    Advanced FileDialog in QML:
    Qt.labs.platform 1.1 FileDialog QML Type:

    In the first article they say everything could change internally. So it sounds very risky. And the second one "labs", some peeps says that those also could change internally so you have to change your code during updates. :o

    Maybe i could wish a feature to the current so the Qt team could add that feature? ? It seems to have been a missing feature for years when we google a bit.

    (For example on the Android side of my app i set a preferred file name into "EXTRA_TITLE" on the Android Intent that calls the Android SAF and that works very fine)

    Someone who know a stable and fresh way to set a preferred file name to a "Windows Save file dialog"?

  • I found a compromise, at least it worked for me.
    I used Qt.labs.platform 1.1 FileDialog QML Type:

    I will just copy my code down:

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

  • @Marco-Medri
    Okay, i took a look at your code and i tested your currentFile-part and it seems to work very good.

    So i hope the Qt community do not make this feature obsolete or something. :o

    Thank you for the help. :)

    And of course, if someone have other ideas you are very welcome.

    EDIT: I am not sure if i should mark this as SOLVED because this are from the "Qt Labs Platform" right?

Log in to reply