how to do add suffix in file Save by QFileDialog



  • 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


  • Moderators

    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"));
    

    ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.