QFileDialog: Select file only from a pre-defined directory
-
wrote on 31 Mar 2017, 14:20 last edited by
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 -
wrote on 31 Mar 2017, 14:47 last edited by Chris Hennes
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 aQDir
and drop thatQStringList
into aQListWidget
.
1/2