PDA

View Full Version : QFileDialog How to hide linux hidden/backup folders (“.folder”)



toglia3d
11th June 2010, 11:01
Basically when browsing folders inside a QFileDialog I find very annoying to have everything bloated with hidden or backup folders (don't know how to call them really); specially on "home" where programs leave their data...

Is there a way to prevent these type of folders (the ones who start with a dot) from showing by default on a QFileDialog?

I'm using Qt4.6, getOpenFileName and Ubuntu 10.04.

P.D.: I spent a couple hours looking for this on the web but found nothing.

tbscope
11th June 2010, 21:54
P.D.: I spent a couple hours looking for this on the web but found nothing.

33 seconds it took to find:
http://doc.qt.nokia.com/4.6/qfiledialog.html#setFilter
which points to
http://doc.qt.nokia.com/4.6/qdir.html#Filter-enum

;-)

toglia3d
12th June 2010, 03:36
Am I not excluding hidden folders with this?

QFileDialog openDialog;
openDialog.setFilter(QDir::Dirs | QDir::Files);
htmlFile = openDialog.getOpenFileName(
this,
tr("Open html file"),
rutaCargarSetting,
tr("*.html *.htm")
);

Doesn't seem to work. I also tried something like:

htmlFile = openDialog.getOpenFileName(
this,
tr("Open html file"),
rutaCargarSetting,
tr("*.html *.htm"),
QDir::Dirs & QDir::Files
);

Doesn't work either.

toglia3d
12th June 2010, 04:44
Sorry for that. it Actually does work. But the getOpenFileName probably is overriding the filters...

I will have to manually exec the dialog.

wysota
12th June 2010, 09:38
QFileDialog::getOpenFileNames() is a static method and (QDir::Dirs & QDir::Files) = 0.

toglia3d
13th June 2010, 18:30
This is off topic.

I find incredibly weird that native dialogs are only intended to show with the static methods. And as I read there is no workaround.

wysota
13th June 2010, 21:09
Sure there is a workaround. Use the native API. Is there something in particular you are missing in the static call?