QFileDialog: Filter directory to include only filenames in QStringList
-
Hello Qt Team,
In QFileDialog, I want to filter by the filenames that are included in a QStringList.Example:
QStringList: ["file1.txt", "file2.txt", ...., fileN.txt]QFileDialog should display: "file1.txt", "file2.txt", ...., "fileN.txt"
I have seen examples for filters like such:
QString selfilter = tr("JPEG (*.jpg *.jpeg)"); QString fileName = QFileDialog::getOpenFileName( this, title, directory, tr("All files (*.*);;JPEG (*.jpg *.jpeg);;TIFF (*.tif)" ), &selfilter );
I just want to display the filenames in the QStringList and I also want to restrict the user to view only to the directory the QFileDialog is initialized to so they should not be able to navigate elsewhere.
-
@anshah said in QFileDialog: Filter directory to include only filenames in QStringList:
I just want to display the filenames in the QStringList
I don't believe you can do that.
To stay in one directory and only offer a passed-in list of filenames is not the job for a
QFileDialog
. You might just as well just present the user with a list of those filenames to pick from, and you don't need to bother showing a directory because you don't want the user to change it or navigate elsewhere.