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. setting default file extension when creating a new file...
Forum Updated to NodeBB v4.3 + New Features

setting default file extension when creating a new file...

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 1.5k Views 4 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.
  • JonBJ JonB

    I don't know what "Haiku" is as an operating system. I can only say that under Ubuntu 22.04 with Qt5 (all I have)

    QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp");
    // or
    QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp", nullptr, QFileDialog::DontUseNativeDialog);
    

    These use native dialog/Qt dialog respectively. Both apply the *.cpp filter from the outset, and neither has a "show all" filter.

    MarisaGM Offline
    MarisaGM Offline
    MarisaG
    wrote on last edited by
    #7

    @JonB let me try a screenshot of what I have or the code I'm using.

    --- https://beos.retro-os.live- support and community for BeOS & Haiku

    1 Reply Last reply
    0
    • MarisaGM Offline
      MarisaGM Offline
      MarisaG
      wrote on last edited by
      #8

      if (maybeSave()) {
      QString fileName = QFileDialog::getOpenFileName(this,
      tr("Open Empire Config"),"", tr("Empire Config Files (*.emp)"));
      if (!fileName.isEmpty())
      loadFile(fileName);
      }

      --- https://beos.retro-os.live- support and community for BeOS & Haiku

      JonBJ 1 Reply Last reply
      0
      • MarisaGM MarisaG

        if (maybeSave()) {
        QString fileName = QFileDialog::getOpenFileName(this,
        tr("Open Empire Config"),"", tr("Empire Config Files (*.emp)"));
        if (!fileName.isEmpty())
        loadFile(fileName);
        }

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

        @MarisaG
        Yep same as mine. Just try *.emp in place of Empire Config Files (*.emp), though it should be same.

        I think actually you are using your OS' native dialog, and that may behave differently (and I don't know whether you can affect it). Try my one with QFileDialog::DontUseNativeDialog and see how that compares/behaves.

        1 Reply Last reply
        0
        • MarisaGM MarisaG

          @JonB I have the filter, and if I manually choose it it gets applied, but I would like the filter to be applied by default and the "show all" filter to be optional. I'm using qt5 on Haiku... And using the qt file dialog.

          M Offline
          M Offline
          mpergand
          wrote on last edited by
          #10

          @MarisaG said in setting default file extension when creating a new file...:

          I have the filter, and if I manually choose it it gets applied, but I would like the filter to be applied by default and the "show all" filter to be optional.

          Try:

          QString fileName = QFileDialog::getOpenFileName(0L,
            "Open Empire Config","", "Empire Config Files (*.emp) ;; All Files (*)");
          
          1 Reply Last reply
          1
          • MarisaGM Offline
            MarisaGM Offline
            MarisaG
            wrote on last edited by
            #11

            That gives me a second "All Files" fiter:
            image.png

            the one at the top is what is already there...

            --- https://beos.retro-os.live- support and community for BeOS & Haiku

            M 1 Reply Last reply
            0
            • MarisaGM MarisaG

              That gives me a second "All Files" fiter:
              image.png

              the one at the top is what is already there...

              M Offline
              M Offline
              mpergand
              wrote on last edited by mpergand
              #12

              @MarisaG
              Not the case in Kubuntu 22.04:
              alt text

              1 Reply Last reply
              0
              • MarisaGM Offline
                MarisaGM Offline
                MarisaG
                wrote on last edited by
                #13

                Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...

                --- https://beos.retro-os.live- support and community for BeOS & Haiku

                Pl45m4P 1 Reply Last reply
                0
                • MarisaGM MarisaG

                  Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...

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

                  @MarisaG said in setting default file extension when creating a new file...:

                  Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...

                  Could be "Haiku" related behavior.
                  Have you tried @JonB 's suggestion here:

                  @JonB said in setting default file extension when creating a new file...:

                  Try my one with QFileDialog::DontUseNativeDialog and see how that compares/behaves.

                  Maybe Haiku adds "All files" by default or so. Don't know. Usually, on Windows, Linux and even Mac (AFAIK) you don't have "All files", when you set a filter which excludes it.


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

                  ~E. W. Dijkstra

                  MarisaGM 1 Reply Last reply
                  0
                  • Pl45m4P Pl45m4

                    @MarisaG said in setting default file extension when creating a new file...:

                    Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...

                    Could be "Haiku" related behavior.
                    Have you tried @JonB 's suggestion here:

                    @JonB said in setting default file extension when creating a new file...:

                    Try my one with QFileDialog::DontUseNativeDialog and see how that compares/behaves.

                    Maybe Haiku adds "All files" by default or so. Don't know. Usually, on Windows, Linux and even Mac (AFAIK) you don't have "All files", when you set a filter which excludes it.

                    MarisaGM Offline
                    MarisaGM Offline
                    MarisaG
                    wrote on last edited by MarisaG
                    #15

                    @Pl45m4 I do want it to look like a native app, so i like the way this is working other than the file list. I rearranged my file layout so that it defaults to looking for the config files for empclient under the system config area so this is not as much a issue anymore.

                    I'm sure i will have more questions LOL.

                    --- https://beos.retro-os.live- support and community for BeOS & Haiku

                    Pl45m4P 1 Reply Last reply
                    0
                    • MarisaGM MarisaG

                      @Pl45m4 I do want it to look like a native app, so i like the way this is working other than the file list. I rearranged my file layout so that it defaults to looking for the config files for empclient under the system config area so this is not as much a issue anymore.

                      I'm sure i will have more questions LOL.

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

                      @MarisaG said in setting default file extension when creating a new file...:

                      I do want it to look like a native app, so i like the way this is working other than the file list

                      Yes, understood. But have you tried it? :)
                      If you try Qt's FileDialog (QFileDialog::DontUseNativeDialog flag set) and there is only one "All Files" left, then you know for sure that it is Haiku's default file dialog that has its own "All Files" (which Qt has no control over).


                      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
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved