Important: Please read the Qt Code of Conduct -

change button text of QFileDialog::getSaveFileName(...)

  • I need help. how can I change the QFialeDialog::getSaveFileName(..) button test "Save" button and I would like to turn it into "New", is it possible to do it? if yes, what codes should I write? thank you very much to those who help me


  • Lifetime Qt Champion


    Can you explain why you want to change the text ?

  • because I have implemented an interface with various options in which you can create a new file without writing anything inside the file but simply create an empty file then with the "New" button then the option to save and go well with QFialeDialog :: getSaveFileName (..) and with the option to open a file and goes well with QFialeDialog :: getOpenFileName (...) while for the option I said before creating a new file (empty file) there is no QFialeDialog :: getNewFileName ( ..) then I thought of using with getSaveFileName (..) and changing the text of the button from "Save" to "New"

  • @Domenico

    Subclass QFileDialog and change the buttons on the buttom right. In fact QFileDialog inherits QDialog, I guess the buttons are the from the dialogs QButtonBox (Documentation is Qt 4.8, dont know, if something has changed in Qt 5)

  • @Pl45m4

    Hi, I tried according to the QDialogButtonBox documentation that inherits it from QFileDialog .. but obtained without success .. can you give me an example in code? thank you!

  • @Domenico

    I won't code the dialog for you, but I would do it this way:
    Create a new class that inherits QFileDialog. Find the buttonBox and get the name of your Save-Button and set it to "New".
    (Maybe you have to create a new button for this).
    BTW: The Save-Button is a StandardButton with a defined ButtonRole => The button text is always the same (depending on the language set). So you can not use StandardButtons, if you want an unique text in there.

    Just found out, that the QButtonRole_Enum @QDialogButtonBox is missing. The link is not connected to the QButtonRole-Enum part of the page (Actually the whole enum explanation is not there, but the link is)

  • Lifetime Qt Champion

    By default the static methods use the native file dialog of the platform so I don't think you can do what you want with that one. You might want to switch to the non-native dialog for more control.

Log in to reply