PDA

View Full Version : Get QFileDialog to display dot folder/files?



drmacro
5th March 2017, 15:29
I did some searching, but, no luck, and, maybe I don't know how to phrase the search...

Using QFileDialog, how do I get it to show files and folders that begin with a period (or dot), for example, in a home folder in Linux you typically have:

/home/user/.config

In this case a folder.

or:

/home/user/.bashrc

In this case a file.

jefftee
5th March 2017, 17:45
You have to tell QFileDialog what to show, by default, hidden files are not shown. Look at the filter options for QFileDialog::setFilters, in particular QDir::Hidden. You probably also want QDir::NoDotAndDotDot, etc.

drmacro
5th March 2017, 18:36
Thanks!

That's the bump I needed. :)

For future readers:



fdlg = QtWidgets.QFileDialog()
fdlg.setFilter(QDir.AllEntries | QDir.Hidden)
if (fdlg.exec()):
fileNames = fdlg.selectedFiles()
fdlg.close()


Shows .name, ..name, folder or files.