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 Updated to NodeBB v4.3 + New Features

FileDialog save file default name

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 5 Posters 4.2k Views 2 Watching
  • 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 12 Dec 2016, 11:46 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

    B 1 Reply Last reply 5 Jan 2017, 12:35
    2
    • E Offline
      E Offline
      enzenb
      wrote on 29 Dec 2016, 12:59 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
        12 Dec 2016, 11:46

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

        Thanks

        B Offline
        B Offline
        benlau
        Qt Champions 2016
        wrote on 5 Jan 2017, 12:35 last edited by benlau 1 May 2017, 12:41
        #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 17 May 2021, 20:36 last edited by
          #4

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

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fcarney
            wrote on 17 May 2021, 21:28 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