How do show in a QFileDialog all files except the executable files?
The only way I can think of is to make a list, but this way I have to anticipate all possible types of files, that is not possible.
Code:
dialog.setNameFilter(tr("All files except .exe (*.png *.xpm *.jpg *.pdf *.gif ............infinite extensions..........)"));
Anyone has a better idea?
Thank you very much.
Re: How do show in a QFileDialog all files except the executable files?
Just use QDialog::setFilter not QDialog::setNameFilter
1 Attachment(s)
Re: How do show in a QFileDialog all files except the executable files?
Sorry, I tried as you say, but does not work.
Code:
#include <QApplication>
#include <QFileDialog>
int main( int argc, char **argv ) {
dialog.
setFilter(QDir::Files);
//<--------------------------All files except executable files.??? dialog.exec();
return 0;
}
Re: How do show in a QFileDialog all files except the executable files?
Quote:
dialog.setFilter(QDir::Files); //<--------------------------All files except executable files.???
Very interesting problem. There is a QDir::Readable, a QDir::Writable, and a QDir::Executable. All three must be combined with QDir::Files. If QDir::Files shows all files, why add one of the three? To show all files + readable, writable, and executable files? Would only make sense if QDir::Files alone shows nothing. Or QDir::Files shows all, but the writable, readable, executable flags actually subtract files with those permissions. Looks like a minor documentation bug to me.
Try: dialog.setFilter(QDir::Files|QDir::Readable|QDir:: Writable);
or: dialog.setFilter(QDir::Files|QDir::executable);
Just as an experiment. What is the result?
Re: How do show in a QFileDialog all files except the executable files?
I tried
dialog.setFilter (QDir:: Files | QDir:: Readable | QDir:: Writable);
and so I see all the files except "exe" but I do not see the folders.
Same problem for these two cases:
dialog.setFilter (QDir:: Dirs | QDir:: Files | QDir:: Readable | QDir:: Writable) and
dialog.setFilter (QDir:: Dirs | QDir:: Files | QDir:: Readable | QDir:: Writable | QDir:: Modified);
Instead
dialog.setFilter (QDir:: Files | QDir:: Executable);
I only see the files. "exe" without all the other folders and files.
Re: How do show in a QFileDialog all files except the executable files?
So,
Quote:
dialog.setFilter (QDir:: Files | QDir:: Readable | QDir:: Writable);
goes into the right direction.
I don't know the solution, but I would now try:
dialog.setFilter (QDir::AllDirs| QDir:: Readable | QDir:: Writable)
Re: How do show in a QFileDialog all files except the executable files?
thanks for your help, but unfortunately it does not work that way. :-(
Re: How do show in a QFileDialog all files except the executable files?
Looks like a Qt bug to me. According to the assistant:
QDir::AllDirs 0x400 List all directories; i.e. don't apply the filters to directory names.
But the executables are filtered. And of course, folders are executable, else it would be impossible to enter them.
At least under Linux.
Re: How do show in a QFileDialog all files except the executable files?
Amazing we found a bug in qt ..... and now how do I solve the problem? what do you do in these situations?
Re: How do show in a QFileDialog all files except the executable files?
Quote:
Originally Posted by
bhodi78
Amazing we found a bug in qt ..... and now how do I solve the problem? what do you do in these situations?
If it is really a bug... let's wait for the answer from the Trolls. We simply might have overlooked something. I filed a bug report. ;)