QFileDialog: Select file only from a pre-defined directory



  • Hi,
    I am looking to select a file (of specified type) from a predefined folder. The idea is to not allow the user to browse; just see the files available in the folder and allow him/her to choose from them. I created a basic implementation for the same using QFileDialog, but have been unable to prevent the user from browsing the file system to search for the file.

    Any help would be much appreciated.
    Thanks



  • I would be inclined to not use QFileDialog for that task -- it's designed to look and function the way users expect a file selection dialog to work, which includes navigation. I have a similar use-case in a program I'm currently working on, and my solution was to create a very simple custom dialog that simply presents a list of the files they are allowed to select from. It's very easy to get that list from a QDir and drop that QStringList into a QListWidget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.