Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. FileDialog save file default name
Forum Update on Monday, May 27th 2025

FileDialog save file default name

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 5 Posters 4.2k 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.
  • M Offline
    M Offline
    MartinD
    wrote on last edited by
    #1

    Hi,
    how to preset file name in qml save file dialog (I want to set some default file name in the dialog)?

    Thanks

    benlauB 1 Reply Last reply
    2
    • E Offline
      E Offline
      enzenb
      wrote on last edited by
      #2

      It's not possible. Even worse, if you reuse the FileDialog, it will default to the last file selected even if this is not what you want. This is one of many bugs and missing features why I think that QtQuick Controls are simply not ready for production use.

      There is no simple workaround but if you are willing to add custom C++ code to your QML project, have a look at Advanced FileDialog in QML, which presents a solution that works on Windows, Mac and Gnome.

      1 Reply Last reply
      1
      • M MartinD

        Hi,
        how to preset file name in qml save file dialog (I want to set some default file name in the dialog)?

        Thanks

        benlauB Offline
        benlauB Offline
        benlau
        Qt Champions 2016
        wrote on last edited by benlau
        #3

        @MartinD Set the folder property of FileDialog to the url of the target folder with the preset file name.

        e.g

        file:/tmp/filename.txt
        
        1 Reply Last reply
        2
        • Z Offline
          Z Offline
          ZergedU
          wrote on last edited by
          #4

          Doesn't appear to be working on windows with Qt 5.15.2?

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            I used qt labs platform. YMMV:

            import Qt.labs.platform 1.1 as QLP
            ...
                QLP.FileDialog {
                    id: filedialog
                    currentFile: "file:///home/user/test2.txt"
                }
            

            C++ is a perfectly valid school of magic.

            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