Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Save file - set preset file name in QML FileDialog? (Windows)
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pga4711
    wrote on last edited by
    #1

    Hello,

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

    How to do this in for example QML FileDialog?
    I found some things:
    Advanced FileDialog in QML: https://www.kullo.net/blog/advanced-filedialog-in-qml/
    Qt.labs.platform 1.1 FileDialog QML Type: https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html

    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 https://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html so the Qt team could add that feature? https://bugreports.qt.io ? 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"?

    1 Reply Last reply
    1
    • M Offline
      M Offline
      Marco Medri
      wrote on last edited by Marco Medri
      #2

      I found a compromise, at least it worked for me.
      I used Qt.labs.platform 1.1 FileDialog QML Type: https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html

      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:///"+myObj.name //The name of the item that you want to save
                  fileMode: Platform.FileDialog.SaveFile
              }
      
      P 1 Reply Last reply
      3
      • M Marco Medri

        I found a compromise, at least it worked for me.
        I used Qt.labs.platform 1.1 FileDialog QML Type: https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html

        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:///"+myObj.name //The name of the item that you want to save
                    fileMode: Platform.FileDialog.SaveFile
                }
        
        P Offline
        P Offline
        pga4711
        wrote on last edited by pga4711
        #3

        @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?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved