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::DoNotUseNativeDialog, the path won't be automatically converted.
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?
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
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?