Important: Please read the Qt Code of Conduct -

Forbid to select certain folder with FileDialog

  • I have a preferences page which allows to select a handful of different locations for files (music, pictures, videos) via a FileDialog. I'd like to forbid selecting the same folder that is already select for another item. For exmaple when the music location is set to /users/bob/music, this folder should not be selectable when setting a folder for the video location. Is that possible and if so, how?

  • @DenverCoder22

    You could store the already selected folders in a QStringList and use a customized Filter proxy derived from QSortFilterProxyModel to allow or deny access to folders.

  • @the_ said:


    Thank you, I'll have a look.

Log in to reply