PDA

View Full Version : QFileDialog: how to filter files with no extension



fatecasino
19th December 2011, 21:14
Hi,

a very quick question,
I am trying to open/filter files with QFileDialog::getOpenFileName which have no extension. Something like document1, document2, etc
My code works so far for .txt and All Files



QString fileName = QFileDialog::getOpenFileName( this, tr("Open HST xy-list(flux vs wave) file..."), sWDir, tr("HST ASCII File (*.txt);;All files (*.*)"), 0, QFileDialog::DontUseNativeDialog );

Oleg
20th December 2011, 09:11
The following code works fine for me in Linux:


QString fileName = QFileDialog::getOpenFileName( this, tr("Open HST xy-list(flux vs wave) file..."), sWDir, tr("HST ASCII File (*.txt);;All files (*)"), 0, QFileDialog::DontUseNativeDialog );

fatecasino
20th December 2011, 11:59
All files (*)
this does not work in windows, it shows simply all files and all extensions. Any ideas?!

fatecasino
21st December 2011, 12:25
nothing new? regular expression perhaps?

Oleg
21st December 2011, 13:43
You can try to reimplement QFileDialog filtering filenames with dots, but standard class cannot do this. Yes, asterisk shows all files without exceptions.

fatecasino
21st December 2011, 16:14
do you mean by using reg expression? I haven't seen anything similar so far. I'll give a try, but if you have something to suggest..more than welcome!

Oleg
21st December 2011, 19:30
Yes, you can use regexp to filter files. But are you sure you really want to hide all files containing dots? Windows thinks that everything after last dot is extension, but actually it can be simply a part of name, like .htaccess files.

fatecasino
14th February 2012, 00:57
believe it or not, I haven't managed to filter filenames with dots.
Actually as I google I haven't seen any example of QRegExp and QFileDialog.
This thread appears in google results as the most representative for this problem :)))