QFileDialog, How to hide the hidden files of showing?
-
@Prmego said in QFileDialog, How to hide the hidden files of showing?:
Hi
If you are ok with using the Qt and not native dialog, you can use QSortFilterProxyModel
http://stackoverflow.com/questions/2101100/qfiledialog-filtering-foldersremember the includes:
#include <QSortFilterProxyModel>
#include <QModelIndex>
#include <QFileSystemModel> -
@Prmego said in QFileDialog, How to hide the hidden files of showing?:
QFileDialog::setFilter
Yes it should, i must have misread/missed docs as it does have
QDir::Hidden
:)
That is of course much easier. -
I have written the following code:
QFileDialog fd; fd.setFilter(QDir::Dirs|QDir::Files|QDir::Drives); QString openFilePath = fd.getOpenFileName(mainWindow, "Open File", lastDirectoryPath, "Text files (*.txt);;All files (*)");
But unfortunately, when I open the OpenDialog I found it still shows the hidden files/directories.
I don't know why that happened. -
@Prmego said in QFileDialog, How to hide the hidden files of showing?:
getOpenFileName
Try with fd.setOption(QFileDialog::DontUseNativeDialog);
-
I have been appended the
setOption
as follow:QFileDialog fd; fd.setFilter(QDir::Dirs|QDir::Files|QDir::Drives); fd.setOption(QFileDialog::DontUseNativeDialog); QString openFilePath = fd.getOpenFileName(mainWindow, "Open File", lastDirectoryPath, "Text files (*.txt);;All files (*)");
But the hidden files/dirs still shows.
-
Hi try
QFileDialog fd;
fd.setFilter(QDir::Dirs|QDir::Files|QDir::Drives);
fd.setOption(QFileDialog::DontUseNativeDialog);
fd.exec();works with win 10 here.
I think the reason the other do not work is due to you using a static function.
Its actually QFileDialog::getOpenFileName(xx)
so it will ignore ANYTHING u set on fd.a static member function is a function that does not need an instance to be be callable.
Even it seem that its via fd. its not. it has its own inner instance and hence the filter you set
on the instance fd, does not come into play.