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. how to do add suffix in file Save by QFileDialog

how to do add suffix in file Save by QFileDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 776 Views 1 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    Hi
    I have following code
    QString fileName = fileDialog->getSaveFileName(getTreeViewHandle(), tr("Csv File"), ".", tr("CSV files (*.csv)"));

    Now my question is if the user issues file

    filelog then how do I add csv suffix if the filename is not filelog.csv that means it does not have an extension

    J.HilkJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      Hi
      I have following code
      QString fileName = fileDialog->getSaveFileName(getTreeViewHandle(), tr("Csv File"), ".", tr("CSV files (*.csv)"));

      Now my question is if the user issues file

      filelog then how do I add csv suffix if the filename is not filelog.csv that means it does not have an extension

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @Qt-Enthusiast

      you check with endsWith() function?

       QString fileName = fileDialog->getSaveFileName(getTreeViewHandle(), tr("Csv File"), ".", tr("CSV files (*.csv)"));
      
      if(!fileName.endsWidth(QString(".csv"))
           fileName.append(QString(".csv"));
      

      ?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      2

      • Login

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