Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved how to add a suffix to a file after saving it on filedialog in qml

    General and Desktop
    qt5 qml filedialog file
    3
    3
    364
    Loading More Posts
    • 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.
    • V
      vinaygopal last edited by

      i have a file dialog which will open up to a perticular location and when the user gives the name i have to add some text to the name of the file and save it how can i do this in filedialog qml object.

      FileDialog{
              id: fileOpenDialog
              objectName: "save_file"
              title: "Save the File"
              folder: defaultpath  // comes from the c++ side
              fileMode: FileDialog.SaveFile
              currentFile: "Export_Script_"+time_stamp 
              nameFilters: [ "Text files (*.txt)" ]
              onAccepted: {
                  fileOpenDialog.close()
                  var filePath = fileOpenDialog.file
                  // how to add a suffix to the filename?
      
              }
              onRejected: {
                  fileOpenDialog.close()
              }
              Component.onCompleted: visible = false
      
          }
      
      1 Reply Last reply Reply Quote 0
      • C
        ChrisW67 last edited by

        Like this?

        filePath = filePath + '.txt'
        
        JuniorMLedesma 1 Reply Last reply Reply Quote 2
        • JuniorMLedesma
          JuniorMLedesma @ChrisW67 last edited by JuniorMLedesma

          Hello, I want to know how to add a suffix to a file after saving it on filedialog in qml and I came here in hope to find my answer. But It makes me sad when I can't find it. I tried filePath = filePath + '.txt' but isn't working for me. Can anyone share a website with me in which I can find the solution? I will be very much thankful to you.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post