[SOLVED] Qt4 QFileDialog getSaveFileName can't overwrite existing file



  • Hi,
    I'm using following line to get filename to save data.
    @const QString fname = QFileDialog::getSaveFileName(this, tr("Datei Speichern unter..."), QDir::toNativeSeparators(savedir + "/" + this->m_fname));@

    In case the file with same filename is already exist(or user selects the existing file), QFileDialog asks user to "Replace or not replace" the file, if user clicks "Yes"(replace existing), QFileDialog shows message box with error like "File can not be saved. Please try again"...

    Selected file at the moment is not locked/opened/used and i can simply delete it with Explorer without any warnings or errors... What can be wrong? How to ignore or deactivate this check in QFileDialog? I only need the filename, it will be checked in another place for existence and write permission...
    I have also tried to set DontConfirmOverwrite, but it just does not shows "Replace or not replace" dialog, but shows the error message anyway....

    Any idea how to get rid of that?

    Me stupid.... MessageBox with error come from my code some lines below.... I hate monday.....


  • Moderators

    are you sure that this message box comes from the QFileDialog?! Because i think it does all you need - just returning the chosen file path.
    I don't believe that there is any check on the file itself in QFileDialog?

    Maybe you do display an Qt generated error message somewhere else in your code?
    You may also try it with a very minimalistic test application just containing the QFileDialog and select the same file again.... to make sure.


Log in to reply
 

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