GrahamL last edited by
Does anyone know how to use QFileDialog to display only directories for which the user has permission to create files in?
I don't think it is possible but if you know a method I'd love to hear it!
There's no reliable way to say if a directory is writable before you actually try to write to it (you can definitely say it's not writable but you can only tell with some probability that it is writable). It would be unreasonable to try to write to every directory so there's no such mode in QFileDialog.
On top of that QFileDialog uses native dialog in some cases and that feature is not usually present in it either.
So I'm afraid you're out of luck.
rturrentine last edited by
One approach we used was to use the directoryEntered signal from the QFileDialog along with a custom proxy filter to handle it. The proxy contained a member variable for the last known good folder. Example code:
void MyProxyModel::DirectoryEntered( const QString& Dir )
QDir CurrentDir( Dir );
// If directory has no contents, reject the change. The isReadable() property is not reliable for some reason, as
// it permits "opening" directories that the user has no permissions for (the result is no entries in the dialog).
if( CurrentDir.entryList().size() == 0 )
CurrentDir = m_LastGoodDir;
m_pFileDialog->setDirectory( CurrentDir );
m_LastGoodDir = CurrentDir;