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. change button text of QFileDialog::getSaveFileName(...)

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.8k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    Domenico
    wrote on last edited by Domenico
    #1

    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

    0_1564058552207_a664b43f-72df-44bc-b0de-c17087183ed3-image.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you explain why you want to change the text ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Domenico
        wrote on last edited by
        #3

        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"

        Pl45m4P 1 Reply Last reply
        0
        • D Domenico

          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"

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @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)


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          D 1 Reply Last reply
          0
          • Pl45m4P Pl45m4

            @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)

            D Offline
            D Offline
            Domenico
            wrote on last edited by Domenico
            #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!

            Pl45m4P 1 Reply Last reply
            0
            • D Domenico

              @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!

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #6

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

              @SGaist
              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)
              :)


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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