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. QFileDialog: choose directories only but show files as well
Forum Updated to NodeBB v4.3 + New Features

QFileDialog: choose directories only but show files as well

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialogqdir
13 Posts 3 Posters 25.8k Views 1 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.
  • M Offline
    M Offline
    michelson
    wrote on last edited by michelson
    #3

    I want to pick dirs ONLY (so the result of if would be the path to the DIR), but able to see files as well. Like you want to choose DIR to read all files of some type from but you want to be able to see the files as well so you know you pick correct folder. So getOpenFileName() doesnt suites here exatcly (or i customize it wrong...).

    mrjjM 1 Reply Last reply
    0
    • M michelson

      I want to pick dirs ONLY (so the result of if would be the path to the DIR), but able to see files as well. Like you want to choose DIR to read all files of some type from but you want to be able to see the files as well so you know you pick correct folder. So getOpenFileName() doesnt suites here exatcly (or i customize it wrong...).

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @michelson
      Ok. I understand.
      Not sure how you can make it show the files but only
      allow to press ok on folder. Not in any easy way.

      It is not an option to let the user also select a file and just snag the path from it ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        michelson
        wrote on last edited by
        #5

        You know, i CAN do that (i mean its just home-use app so its not a big deal it wont work as i want) but for the sake of good-looks of a whole project i wanted to at least try to implement this one thing :D

        mrjjM 1 Reply Last reply
        0
        • M michelson

          You know, i CAN do that (i mean its just home-use app so its not a big deal it wont work as i want) but for the sake of good-looks of a whole project i wanted to at least try to implement this one thing :D

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @michelson
          Well there is a lot of flags. But there is not one that sounds like such function.
          (in my head)
          You could make your own dialog but that
          somewhat a lot of work to NOT select a file.

          You could also make it 2 step.
          First select folder
          Then dialog comes with all files , each checked and u can exclude some if needed
          or else press ok to proceed.
          That way is 100% want you want and serves a function.

          1 Reply Last reply
          0
          • Hamed.MasafiH Offline
            Hamed.MasafiH Offline
            Hamed.Masafi
            wrote on last edited by
            #7
            QFileDialog dialog;
            dialog.setFileMode(QFileDialog::DirectoryOnly);
            dialog.setOption(QFileDialog::ShowDirsOnly, false);
            dialog.exec();
            qDebug() << dialog.directory();
            

            Remote object sharing (OO RPC)
            http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

            Advanced, Powerful and easy to use ORM for Qt5
            https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

            mrjjM 1 Reply Last reply
            0
            • Hamed.MasafiH Hamed.Masafi
              QFileDialog dialog;
              dialog.setFileMode(QFileDialog::DirectoryOnly);
              dialog.setOption(QFileDialog::ShowDirsOnly, false);
              dialog.exec();
              qDebug() << dialog.directory();
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @Hamed.Masafi
              Hi
              it looks good but its not showing files here on win 7.
              Only the dirs.
              On your platform, it does show all files also?

              Hamed.MasafiH 1 Reply Last reply
              0
              • mrjjM mrjj

                @Hamed.Masafi
                Hi
                it looks good but its not showing files here on win 7.
                Only the dirs.
                On your platform, it does show all files also?

                Hamed.MasafiH Offline
                Hamed.MasafiH Offline
                Hamed.Masafi
                wrote on last edited by Hamed.Masafi
                #9

                @mrjj said:

                Hi
                it looks good but its not showing files here on win 7.
                Only the dirs.
                On your platform, it does show all files also?

                Hi, on my platform (debian + kde) works well. But we can take a test.
                Please change second line to flowing code and test again.

                dialog.setFileMode(QFileDialog::Directory);
                

                Remote object sharing (OO RPC)
                http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                Advanced, Powerful and easy to use ORM for Qt5
                https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                mrjjM 1 Reply Last reply
                0
                • Hamed.MasafiH Hamed.Masafi

                  @mrjj said:

                  Hi
                  it looks good but its not showing files here on win 7.
                  Only the dirs.
                  On your platform, it does show all files also?

                  Hi, on my platform (debian + kde) works well. But we can take a test.
                  Please change second line to flowing code and test again.

                  dialog.setFileMode(QFileDialog::Directory);
                  
                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Hamed.Masafi
                  Ok, must be different on win
                  Hmm am i blind or is that same line?

                  1 Reply Last reply
                  0
                  • Hamed.MasafiH Offline
                    Hamed.MasafiH Offline
                    Hamed.Masafi
                    wrote on last edited by
                    #11

                    Oh, sorry. My mistake

                    dialog.setFileMode(QFileDialog::Directory);
                    

                    Remote object sharing (OO RPC)
                    http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                    Advanced, Powerful and easy to use ORM for Qt5
                    https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      michelson
                      wrote on last edited by
                      #12

                      @Hamed.Masafi
                      Unfortunetly i can confirm @mrjj issiue - Win7 OS still couses files to be invisible. I guess problem cant be solved easily @ Win OS - i think the only way is to reimplement QFileDialog which for me is just not worth the time it will take for such trivial thing.

                      1 Reply Last reply
                      0
                      • Hamed.MasafiH Offline
                        Hamed.MasafiH Offline
                        Hamed.Masafi
                        wrote on last edited by
                        #13

                        I've tested on windows. It seems the only possible solution is to ignore native dialog.

                        QFileDialog dialog;
                        dialog.setFileMode(QFileDialog::DirectoryOnly);
                        dialog.setOption(QFileDialog::DontUseNativeDialog, true);
                        dialog.setOption(QFileDialog::ShowDirsOnly, false);
                        dialog.exec();
                        qDebug() << dialog.directory();
                        

                        Remote object sharing (OO RPC)
                        http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                        Advanced, Powerful and easy to use ORM for Qt5
                        https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                        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