[SOLVED] Disable file name box in QFileDialog


I used a QFileDialog to open a browser.
Here is my code:

QString filePath = QFileDialog::getSaveFileName(this,
                                               "Export Xml", "PluginPythonQt",
                                                "Xml files (*.xml)");

When excute it will show a dialog like this:

enter image description here

I want to disable the “File name:” box in the picture or prevent user to enter a new name. How can i do that ? Thanks.


I believe you can’t achieve this — save dialog is about choosing name besides the choosing where to save it. Of course, you might just ignore what user typed and force your name when he hits OK but it will just make the user angry.

Better way, in my opinion, is to use QFileDialog::getExistingDirectory which will allow the user to choose where to save the file but won’t allow him to choose the file name. It will be fair, at least.

Answered By – ixSci

Answer Checked By – Dawn Plyler (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *