QFileDialog::DontConfirmOverwrite doesn't seem to work
-
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.
-
QFileDialog::getSaveFileName() is
static
so the first sample code isn't going to respectDontConfirmOverwrite
. 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 viaexec()
)? -
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?
-
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?
@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.