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 set preset file name
Qt 6.11 is out! See what's new in the release blog

FileDialog set preset file name

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 380 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
    Mihaill
    wrote on last edited by
    #1

    How set preset file name in FileDialog ?
    If I do this:

    QLP.FileDialog {
                        id: fileDialogSaveFile
                        title: qsTr("Select file")
                        nameFilters: [ "JSON files (*.json)" ]
                        currentFile: "1234"
                        fileMode: QLP.FileDialog.SaveFile
    

    then I get preset like: "/qml/frames/aboutProgram/1234.json" - it's path in frames

    1 Reply Last reply
    0
    • DiackneD Offline
      DiackneD Offline
      Diackne
      wrote on last edited by
      #2

      Hi,
      i think your problem is in the currentFile: you need to set all path and need to be valid more the new file name like

      QLP.FileDialog {
                          id: fileDialogSaveFile
                          title: qsTr("Select file")
                          nameFilters: [ "JSON files (*.json)" ]
                          currentFile: StandardPaths.writableLocation(StandardPaths.DownloadLocation) + "/" + 1234 
                          folder: StandardPaths.writableLocation( StandardPaths.DownloadLocation)
                          fileMode: QLP.FileDialog.SaveFile
      
      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