When I set up a QFileDialog - either with the easy static functions or with the constructors - to filter only a specific file extension. By default, the (non-native) QFileDialog greys out the not filtered entries.
Is there a way to make the dialog to hide these entries completely?
@
QStringList filters;
filters << "Module Dll's (_qtmdl.dll)"
<< "Dll's (.dll)"
<< "All Files (*)";

After a bit of research I found a solution. It is made by accessing the underlying QFileSystemModel via subclassing the QSortFilterProxyModel:
@
// this is the first part subclassing
// the QSortFilterProxyModel
//
class FileFilterProxyModel : public QSortFilterProxyModel
{
protected:
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
QFileSystemModel* fileModel = qobject_cast<QFileSystemModel*>(sourceModel());
fileModel->setNameFilterDisables(false);
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
};@

@
// this is further down in the code, setting up
// and executing the QFileDialog

I'm not sure whether the default sorting of the FileDialog still works. Is there a function that influences sorting?

Although it works, I find it pretty awkward to subclass and object-cast just to change a setting in the filter. Is there a more elegant way to do this? Probably instead of implementing filterAcceptsRow(), implementing the constructor?