Results 1 to 3 of 3

Thread: QFileDialog::getSaveFileName fails to set initial folder within sandbox container

  1. #1

    Default QFileDialog::getSaveFileName fails to set initial folder within sandbox container

    In a sandboxed Qt app on Mac OS X Lion, the application data folder sits within the sandbox container. The path looks like this: ~/Library/Containers/bundleID/Data/Library/Application Support/CompanyName/ApplicationName/ . I would like to open a save file dialog and set its default folder to ~/Library/Containers/bundleID/Data/Library/Application Support/CompanyName/ApplicationName/folder1. The code I use is:

    QString sPath=QFileDialog::getSaveFileName(this,tr("Save File"),"~/Library/Containers/bundleID/Data/Library/Application Support/CompanyName/ApplicationName/folder1/untitled.txt",tr("text files (*.txt"));

    However, when the dialog is opened, the default path is changed to "~/Library/Application Support/CompanyName/ApplicationName/folder1/", which is exactly the same path in the application folder before sandbox is applied. It seems the QFileDialog::getSaveFileName function automatically converts a path from the sandboxed version to the unsandboxed version. That creates a problem for our particular application.

    By the way, if I use the option QFileDialog:oNotUseNativeDialog, the path won't be automatically converted.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QFileDialog::getSaveFileName fails to set initial folder within sandbox container

    So, if Qt uses the native dialog and gives it your path then the Mac OS X operating system does something funny with it. Are sure that if you write there that OS X is not redirecting the file on your behalf?

  3. #3

    Default Re: QFileDialog::getSaveFileName fails to set initial folder within sandbox container

    No. It won't redirect it. It will be written to the wrong location if I leave it as it is.

    Quote Originally Posted by ChrisW67 View Post
    So, if Qt uses the native dialog and gives it your path then the Mac OS X operating system does something funny with it. Are sure that if you write there that OS X is not redirecting the file on your behalf?

Similar Threads

  1. QFileDialog::getSaveFileName() issue on Max OS X 10.8
    By AndyBrice in forum Qt Programming
    Replies: 3
    Last Post: 20th June 2013, 11:47
  2. QInputDialog like QFileDialog::getSaveFileName
    By BIllNo123 in forum Newbie
    Replies: 5
    Last Post: 23rd September 2010, 14:51
  3. problem with QFileDialog::getSaveFileName
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2009, 07:38
  4. A question about QFileDialog::getSaveFileName
    By Ali in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 19:46
  5. QFileDialog::getSaveFileName issues with filename
    By dugs in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2006, 17:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.