QFileDialog showing hidden files although system setting is off

1.4k Views Asked by At

I am using the following code to show an open dialog in Qt:

QString path = QFileDialog::getOpenFileName(this, tr("Open Config File"), QDir::rootPath(), "Text Files (*.txt *.csv *.*);;");

What I realised is that this dialog also shows hidden files although the system setting for showing hidden files is turned off. It's the same if I instantiate the QFileDialog manually and show it. I also couldn't find out how to turn this off via a filter.

Does anyone know if there is a way to achieve the desired behaviour?

1

There are 1 best solutions below

4
ixSci On

Looks like there is no simple(by setting some flag) solution out there. So I recommend to use the filtering which is described in other SO answer. But in your case you might use the following condition:

if(fileModel != nullptr)
{
    QFileInfo info = fileModel->fileInfo(index0);
    return info.isHidden();
}
return false;