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. QFileDialog::DontConfirmOverwrite doesn't seem to work
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::DontConfirmOverwrite doesn't seem to work

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 198 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.
  • G Offline
    G Offline
    gabello306
    wrote on last edited by
    #1

    I am having trouble with QFileDialog::DontConfirmOverwrite. I doesn't seem to work properly. I have tried setting a couple of different methods and I still get the confirmation box. I want to display my own QMessageBox instead of the default overwrite box. I have tried the following:

        QFileDialog file;
        file.setOptions(QFileDialog::DontConfirmOverwrite);
        QString filename = file.getSaveFileName( this, tr ( "Save As" ),
            m_pGlobal->currDirectory, tr ( "All Files (*.*)" ) );
    
    

    and

    QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), 
        m_pGlobal->currDirectory, tr("All Files (*.*)"),
        nullptr, QFileDialog::DontConfirmOverwrite);
    

    Both of these options display the Confirm Overwrite box. Any ideas on how to get rid of it? I am using Redhat 9 and Qt 5.

    1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      QFileDialog::getSaveFileName() is static so the first sample code isn't going to respect DontConfirmOverwrite. But second example looks right.

      Is it using the Qt or your native dialog? Try QFileDialog::DontConfirmOverwrite | QFileDialog::DontUseNativeDialog? Does it make any difference if you make the first code with the instance work (by going via exec())?

      1 Reply Last reply
      1
      • G Offline
        G Offline
        gabello306
        wrote on last edited by
        #3

        The exec on the first code doesn't work. The exec executes after the response from the getSaveFileName. The DontUseNativeDialog works as it doesn't put up the overwrite message, but the style is all wrong on the menu.. Is there a way to change the style of the menu?

        JonBJ 1 Reply Last reply
        0
        • G gabello306

          The exec on the first code doesn't work. The exec executes after the response from the getSaveFileName. The DontUseNativeDialog works as it doesn't put up the overwrite message, but the style is all wrong on the menu.. Is there a way to change the style of the menu?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @gabello306
          So the implication is:

          • By default it's using your native windowing system and I presume either that does not support the "suppress overwrite" warning or the Qt call to it is not right. I don't know which.
          • If you use DontUseNativeDialog that uses Qt code and correctly suppresses the warning. But the style will be quite different from the native dialog. You don't like it, and I don't know how much you can restyle it. It won't look the same as the native one.
          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