QDirModel::setNameFilters(...) not working
Hi,
I want to create a QTreeView that only shows dirs and JPEG-files. When I pass end empty filter QStringList to the QDirModel constructor I can see all Dirs and Files, as expected. But when I try the same thing with a non-empty StringList I don't see anything.
This snippet shows everything (since I create an empty StringList:
Code:
QDir::Files|QDir
::Dirs|QDir
::Readable|QDir
::NoDotAndDotDot, \
QDir::Name|QDir
::DirsFirst,
this);
This snippet doesn't show anything at all:
Code:
ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
QDir::Files|QDir
::Dirs|QDir
::Readable|QDir
::NoDotAndDotDot, \
QDir::Name|QDir
::DirsFirst,
this);
Help appreciated, thx
Re: QDirModel::setNameFilters(...) not working
Hi,
is
Code:
filemodel
= new QDirModel(QStringList(), Dir
::Files|QDir
::Dirs|QDir
::Readable|QDir
::NoDotAndDotDot,
QDir::Name|QDir
::DirsFirst,
this);
ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
filemodel->setNameFilters(ffilter);
working?
Lykurg
Re: QDirModel::setNameFilters(...) not working
no, assigning the filter after creating the DirModel doesn't work either. Same problem, the Treeview is empty.
Re: QDirModel::setNameFilters(...) not working
Please add :
filemodel ->setFilter( QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot );
I tried and worked !:)