PDA

View Full Version : QDirModel::setNameFilters(...) not working



Kraut~salat
25th December 2008, 01:05
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:


filemodel = new QDirModel(QStringList(), \
QDir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotA ndDotDot, \
QDir::Name|QDir::DirsFirst, this);

This snippet doesn't show anything at all:

QStringList ffilter;
ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
filemodel = new QDirModel(ffilter, \
QDir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotA ndDotDot, \
QDir::Name|QDir::DirsFirst, this);

Help appreciated, thx

Lykurg
25th December 2008, 10:34
Hi,

is
filemodel = new QDirModel(QStringList(), Dir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotAn dDotDot, QDir::Name|QDir::DirsFirst, this);
QStringList ffilter;
ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
filemodel->setNameFilters(ffilter);


working?

Lykurg

Kraut~salat
25th December 2008, 14:07
no, assigning the filter after creating the DirModel doesn't work either. Same problem, the Treeview is empty.

damonlin
11th January 2009, 10:54
Please add :

filemodel ->setFilter( QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot );

I tried and worked !:)