1

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?

Mat
  • 202,337
  • 40
  • 393
  • 406
bweber
  • 3,772
  • 3
  • 32
  • 57
  • I just tried it on ubuntu and here it seems the other way around: it never shows hidden files. But I don't know if there is something like a system wide setting for this on Linux. – bweber May 08 '15 at 06:39
  • I cannot reproduce this on Windows 7 and Qt 4.8.5. I see the native file dialog and its content corresponds to the system's settings. – vahancho May 08 '15 at 06:44
  • I'm also using Qt 5.4. – bweber May 08 '15 at 06:48

1 Answers1

1

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;
Community
  • 1
  • 1
ixSci
  • 13,100
  • 5
  • 45
  • 79
  • Hm...ok. I think if this is really a Qt-problem I'm going to let it be for now. If I used your solution I still would have to find out what the system setting is and then act accordingly. Maybe they fix it in on of the next releases. It's not that much of a problem, just very annoying for the user. – bweber May 08 '15 at 06:53
  • I don't think it is a problem at all. The settings you are talking about are the Explorer settings and I don't see why other apps should regard these settings. – ixSci May 08 '15 at 06:56
  • On the other hand Qt claims it uses native dialog by default and if that's the case then Explorer settings should be acknowledged. Strange. – ixSci May 08 '15 at 07:00
  • 1
    Well, unlike on Linux there is only one file browser on Windows so I think the settings the user selects there should be respected everywhere, especially if it's a supposedly 'native' file dialog. – bweber May 08 '15 at 07:05