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. [SOLVED] Problem since Qt4.8 to select bundle with QFileDialog
Forum Update on Monday, May 27th 2025

[SOLVED] Problem since Qt4.8 to select bundle with QFileDialog

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 3.3k 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.
  • D Offline
    D Offline
    deac
    wrote on 31 May 2013, 08:53 last edited by
    #1

    Hello,

    I have a problem with QFileDialog with Qt4.8.

    I worked so far with Qt4.6.3 32bits on Mac 0S X 10.8.6. The problem was not in Qt4.6.
    It appeared when I tried moving to 4.8.4 32bits.

    The problem appears I try to select programatically a Mac « bundled directory » when creating a QFileFialog. The bundle should be considered as a standard file on the mac, not as a directory.

    With Qt4.6 it works well : the Bundle is selected in the QFileDialog.
    But with Qt4.8.4 the QFileDialog goes into (opens) the bundle with no file selected : the bundle is treated as a standard directory.

    If I go back into the repository where the bundle is, then select the bundle manually, I can’t go inside, which is normal.
    Hence, the problem appears when selecting the bundle programatically, but not « manually ».

    Here is a code example:
    @QFileDialog fileDialog(g_mainWindow,
    tr("Save project as"),
    "/Applications",
    "application (*.app)");

    fileDialog.setAcceptMode(QFileDialog::AcceptSave);
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.selectFile("iCal.app");
    //fileDialog.setOption(QFileDialog::DontUseNativeDialog);
    

    @

    ⇨ /Applications/iCal.app is a bundle
    ⇨ the QFileDialog ends in the /Applications/iCal.app directory where it should end in /Applications/ and SELECT /Applications/iCal.app

    I tried to use setOption(QFileDialog::DontUseNativeDialog), it works fine with Qt4.8, but the look of the window is not that I want.

    I also tried using a static method of QFileDialog, but it doesn’t work better.

    I do not find anything about this, in documentation, nor support forum, nor release notes.
    Have you any idee ?
    Thanks very much,

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deac
      wrote on 5 Jun 2013, 08:38 last edited by
      #2

      Hello,

      I have made other searchs and I found it is appear between Qt4.6.3 and Qt4.7.0.
      I have post a bug report :
      https://bugreports.qt-project.org/browse/QTBUG-31562

      Meanwhile resolution, have you any idea to bypass this problem ?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 5 Jun 2013, 19:56 last edited by
        #3

        Hi and welcome to devnet,

        If you are not afraid of building Qt i've submitted a patch to gerrit (still needs to be reviewed though) that would solve your problem.

        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
          deac
          wrote on 7 Jun 2013, 07:50 last edited by
          #4

          Thank you for your answer !
          I try it and it works well. I hope this modification will appear in the next version.
          I have comment the bugreport with a link to your patch.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 9 Jun 2013, 22:15 last edited by
            #5

            You're welcome !

            The modification has been approved and pushed to the gitorious repo :)

            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
              deac
              wrote on 20 Jun 2013, 07:38 last edited by
              #6

              Hello,

              Thanks very much for your answers.
              The patch works well with the .app bundles, but not with all others.
              I have found that there is a problem with the function IsBundle(), that is used by the patch.
              The function QFileInfo::isbundle() return false for some bundles and true for others.
              I tested Qt4.6 32bits, Qt4.8 32bits and 4.8 64bits. All have the bug.

              So the new QFileDialog doesn’t work for some bundle.

              I created a bugId in the bugreport : https://bugreports.qt-project.org/browse/QTBUG-31884

              Test protocole with my application :

              • An application declares a bundle document in its info.plist (IsBundle.app declares .qtbu as document)
              • I move the application to let the system takes care of the info.plist
              • This application creates a bundle with QDir().mkdir()
                o The Finder understands it is a bundle, thanks to the info.plist
                o The function QFileInfo ::isbundle() returns false. It should return true.
              • I create a directory with the finder called Test.qtbu
                o The Finder understands it is a bundle, thanks to the info.plist
                o The function QFileInfo ::isbundle() returns false. It should return true.

              Test protocole with iDVD :

              • iDVD is an application delivered by default by my mac.
              • I create TestA.dvdproj with iDVD
                o QFileInfo ::isbundle() returns true
              • I create TestB.dvdproj with the Finder
                o QFileInfo() ::isbundle() returns false. It should return true.

              A bundle is just a directory with an extension, so in all cases the function QFileInfo::isBundle() should in all these cases return true.

              I have browsed the Qt sources and found possible causes.

              I found in the Qt’s code that a function of mac is used : CFBundleGetPackageInfoInDirectory.
              This function is normaly used to find the creator and the type of the bundle and return false if not found. I think this function can’t assure that the directory is a bundle, juste if it is a bundle with a creator and type.
              Hence, it should not be used by QFileInfo() ::isbundle() . It is not the proper function to use there, I think.

              I also found in the .dvdproj a little file named Pkginfo. This file contains the creator and the type. But the Mac OS documentation explains this file is not necessary but can improve performance for code that accesses this information :
              https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigApplications.html

              • To confirme that, if I remove this file from TestA.dvdproj, it is still recognize as bundle in the Mac OS Finder AND by the test application.
              • If I add this file in a bundle, the function QFileInfo ::isbundle() return true but it is not a solution, this file is not in all bundles.
              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 20 Jun 2013, 19:44 last edited by
                #7

                Hi,

                You're welcome.

                Thanks for the very detailed bug report. I'll see what I can do

                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
                  deac
                  wrote on 26 Jun 2013, 07:37 last edited by
                  #8

                  Hello,

                  I'm following your patch in review, thinks for your implication !

                  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