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

QFileDialog: choose directories only but show files as well

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialogqdir
13 Posts 3 Posters 25.2k Views
  • 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 27 Dec 2015, 14:33 last edited by
    #1

    Hello,
    I would like to have aQFileDialog from which i will be able to choose dirs but meanwhile i should be able to see files in them as well. I tired:
    QString path = QFileDialog::getExistingDirectory(this, tr("Choose catalog"), ".", QFileDialog::ReadOnly);
    I can choose dirs and thats ok but i cant see any files, any help?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Dec 2015, 14:39 last edited by
      #2

      hi
      And
      QFileDialog::getOpenFileName();
      is not what you want?
      It's a normal file open?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        michelson
        wrote on 27 Dec 2015, 15:07 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...).

        M 1 Reply Last reply 27 Dec 2015, 15:12
        0
        • M michelson
          27 Dec 2015, 15:07

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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 27 Dec 2015, 15:12 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 27 Dec 2015, 15:21 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

            M 1 Reply Last reply 27 Dec 2015, 15:25
            0
            • M michelson
              27 Dec 2015, 15:21

              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

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 27 Dec 2015, 15:25 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
              • H Offline
                H Offline
                Hamed.Masafi
                wrote on 27 Dec 2015, 15:55 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

                M 1 Reply Last reply 27 Dec 2015, 16:09
                0
                • H Hamed.Masafi
                  27 Dec 2015, 15:55
                  QFileDialog dialog;
                  dialog.setFileMode(QFileDialog::DirectoryOnly);
                  dialog.setOption(QFileDialog::ShowDirsOnly, false);
                  dialog.exec();
                  qDebug() << dialog.directory();
                  
                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 27 Dec 2015, 16:09 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?

                  H 1 Reply Last reply 27 Dec 2015, 20:31
                  0
                  • M mrjj
                    27 Dec 2015, 16:09

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

                    H Offline
                    H Offline
                    Hamed.Masafi
                    wrote on 27 Dec 2015, 20:31 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

                    M 1 Reply Last reply 27 Dec 2015, 20:33
                    0
                    • H Hamed.Masafi
                      27 Dec 2015, 20:31

                      @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);
                      
                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 27 Dec 2015, 20:33 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
                      • H Offline
                        H Offline
                        Hamed.Masafi
                        wrote on 28 Dec 2015, 05:53 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 28 Dec 2015, 09:55 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
                          • H Offline
                            H Offline
                            Hamed.Masafi
                            wrote on 28 Dec 2015, 10:02 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

                            8/13

                            27 Dec 2015, 16:09

                            • Login

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