I want to show all the files in the QFileDialog and hide the directories of a certain directory,while the QFileDialog provides ShowDirsOnly Options without ShowFilesOnly.
How can I resolve this issue ?
Printable View
I want to show all the files in the QFileDialog and hide the directories of a certain directory,while the QFileDialog provides ShowDirsOnly Options without ShowFilesOnly.
How can I resolve this issue ?
Hi, maybe QFileDialog::setFileMode() helps.
Ginsengelf
Why would you want to deny people the ability to browse for their files?
I have solved this issue,using a QFileDialog object instead of QFileDialog static function getOpenFileName().
Following:
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDirectory("/home/user1");
dialog.setFilter(QDir::Files);
dialog.setWindowTitle("Open File");
dialog.setNameFilter("Images(*.jpg *.gif *.bmp)");
dialog.exec();
QString file = dialog.selectedFiles().first();
// ... ...