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. [SOLVED] Qt4 QFileDialog getSaveFileName can't overwrite existing file

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k 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.
  • A Offline
    A Offline
    AcerExtensa
    wrote on last edited by
    #1

    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.....

    God is Real unless explicitly declared as Integer.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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