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. QFileDialog
QtWS25 Last Chance

QFileDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialog
3 Posts 3 Posters 1.2k 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.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hi
    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!

    Thanks

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rturrentine
        wrote on last edited by
        #3

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

        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