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::getOpenFileName can't jump to the right directory on mac
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::getOpenFileName can't jump to the right directory on mac

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 1.4k 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.
  • P Offline
    P Offline
    Princein
    wrote on last edited by
    #1

    Hi:
    I developed a cross-platform qt app which works on both mac and windows, in my app, I want to get a file from my mac, so I use QFileDialog, here is my code:

    QString qstr_path = QFileDialog::getOpenFileName(this, tr("Open Project"), projdir_qstr, "allfiles(*.bundle)");
    
    

    int the mac which macosx is 10.14,and the projdir_qstr = /Users/lee/Library/Caches/FUCreator/Projects/,it work very fine,can show me the 'Projects' directory.
    but the other mac which macosx is 10.13,and the projdir_qstr = /Users/FaceUnity/Library/Caches/FUCreator/Projects/,it can't open the 'Projects' directory,only shows me the 'Users' directory,here is the picture:
    alt text

    I don't know why, could you help me, thanks a lot!

    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • P Princein

      Hi:
      I developed a cross-platform qt app which works on both mac and windows, in my app, I want to get a file from my mac, so I use QFileDialog, here is my code:

      QString qstr_path = QFileDialog::getOpenFileName(this, tr("Open Project"), projdir_qstr, "allfiles(*.bundle)");
      
      

      int the mac which macosx is 10.14,and the projdir_qstr = /Users/lee/Library/Caches/FUCreator/Projects/,it work very fine,can show me the 'Projects' directory.
      but the other mac which macosx is 10.13,and the projdir_qstr = /Users/FaceUnity/Library/Caches/FUCreator/Projects/,it can't open the 'Projects' directory,only shows me the 'Users' directory,here is the picture:
      alt text

      I don't know why, could you help me, thanks a lot!

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

      @Princein

      Hi

      Have you checked if the path is valid (all directories exist)?

      In general it's better to use QStandardPath and then navigate through your project directory / AppDir, instead of hardcoding the whole path.

      It ensures, that you start in that directory, where your program is executed (especially if you work with multiple systems / devices)


      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
      • P Princein

        Hi:
        I developed a cross-platform qt app which works on both mac and windows, in my app, I want to get a file from my mac, so I use QFileDialog, here is my code:

        QString qstr_path = QFileDialog::getOpenFileName(this, tr("Open Project"), projdir_qstr, "allfiles(*.bundle)");
        
        

        int the mac which macosx is 10.14,and the projdir_qstr = /Users/lee/Library/Caches/FUCreator/Projects/,it work very fine,can show me the 'Projects' directory.
        but the other mac which macosx is 10.13,and the projdir_qstr = /Users/FaceUnity/Library/Caches/FUCreator/Projects/,it can't open the 'Projects' directory,only shows me the 'Users' directory,here is the picture:
        alt text

        I don't know why, could you help me, thanks a lot!

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Princein I can't see the picture.
        Is /Users/FaceUnity/Library/Caches/FUCreator/Projects a valid path? Can you open it in Finder?
        Also, do you have access to all these directories in the path?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        P 1 Reply Last reply
        0
        • P Offline
          P Offline
          Princein
          wrote on last edited by
          #4

          here is the picture:

          alt text

          jsulmJ 1 Reply Last reply
          0
          • P Princein

            here is the picture:

            alt text

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Princein I still can't see it. File upload often does not work here. You can upload it to some file sharing service and post a link here.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            P 1 Reply Last reply
            0
            • jsulmJ jsulm

              @Princein I can't see the picture.
              Is /Users/FaceUnity/Library/Caches/FUCreator/Projects a valid path? Can you open it in Finder?
              Also, do you have access to all these directories in the path?

              P Offline
              P Offline
              Princein
              wrote on last edited by
              #6

              @jsulm yes, the /Users/FaceUnity/Library/Caches/FUCreator/Projects is a valid path!, I use the 'open' command can open the /Users/FaceUnity/Library/Caches/FUCreator/Projects directory,but use the QFileDialog::getOpenFileName can't open the 'Projects' and shows me the 'Users' directory!

              J.HilkJ 1 Reply Last reply
              0
              • P Princein

                @jsulm yes, the /Users/FaceUnity/Library/Caches/FUCreator/Projects is a valid path!, I use the 'open' command can open the /Users/FaceUnity/Library/Caches/FUCreator/Projects directory,but use the QFileDialog::getOpenFileName can't open the 'Projects' and shows me the 'Users' directory!

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @Princein what qt version is this?


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                P 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Princein I still can't see it. File upload often does not work here. You can upload it to some file sharing service and post a link here.

                  P Offline
                  P Offline
                  Princein
                  wrote on last edited by
                  #8

                  @jsulm https://github.com/iOSPrincekin/Qt/blob/master/QA/10.png

                  1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @Princein what qt version is this?

                    P Offline
                    P Offline
                    Princein
                    wrote on last edited by
                    #9

                    @J.Hilk Qt 5.6.1, because my company code history reason, I must use the Qt 5.6.1!

                    J.HilkJ 1 Reply Last reply
                    0
                    • P Princein

                      @J.Hilk Qt 5.6.1, because my company code history reason, I must use the Qt 5.6.1!

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @Princein
                      IIRC there was a problem with getOpenFileName in one of the 5.12 releases, but that clearly does not apply to your case...


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      P 1 Reply Last reply
                      0
                      • J.HilkJ J.Hilk

                        @Princein
                        IIRC there was a problem with getOpenFileName in one of the 5.12 releases, but that clearly does not apply to your case...

                        P Offline
                        P Offline
                        Princein
                        wrote on last edited by
                        #11

                        @J.Hilk said in QFileDialog::getOpenFileName can't jump to the right directory on mac:

                        in
                        IIRC there was a problem with getOpenFileName in one of the 5.12 releases, but that clearly does not apply to your case...

                        but, I certainly have this problem, what should I do? can you give me some suggestion!

                        J.HilkJ 1 Reply Last reply
                        0
                        • P Princein

                          @J.Hilk said in QFileDialog::getOpenFileName can't jump to the right directory on mac:

                          in
                          IIRC there was a problem with getOpenFileName in one of the 5.12 releases, but that clearly does not apply to your case...

                          but, I certainly have this problem, what should I do? can you give me some suggestion!

                          J.HilkJ Offline
                          J.HilkJ Offline
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #12

                          @Princein
                          well get the source qt (QtBase- module) and inspect the QFileDialog class.

                          Fix it and compile it.

                          You should check if your issue is still there with the latest QtVersion and if it's fixed there, you can simply compare the source code to find and fix the issue


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          P 1 Reply Last reply
                          0
                          • J.HilkJ J.Hilk

                            @Princein
                            well get the source qt (QtBase- module) and inspect the QFileDialog class.

                            Fix it and compile it.

                            You should check if your issue is still there with the latest QtVersion and if it's fixed there, you can simply compare the source code to find and fix the issue

                            P Offline
                            P Offline
                            Princein
                            wrote on last edited by
                            #13

                            @J.Hilk thanks a lot!

                            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