QFileDialog
-
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.
-
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;
}