PDA

View Full Version : Filtering "NoDotDot" in filesystem model not working



aurora
3rd May 2012, 10:21
Hi ,
I using filesystem model in my program to display the filesystems....
Its working fine, it displays all the files and directoris including Dot and DotDot....
But i dont want to display the "DotDot" hence i used filter as shown below, unfortunately its not working....IT DISPLAYS DOTDOT ALSO....
Please somebody tell me whats wrong here...


QString sPath=ui->lineEdit_directory->text();
dirmodel =new QFileSystemModel(this);
dirmodel->setFilter(QDir::AllDirs | QDir::Dirs |QDir::NoDotDot); <---HERE "QDir::NoDotDot" IS NOT WORKING


dirmodel->setRootPath(sPath);
ui->treeView->setModel(dirmodel);
ui->treeView->setRootIndex(dirmodel->index(sPath));

folibis
3rd May 2012, 11:53
http://qt-project.org/doc/qt-4.8/qdir.html#Filter-enum
QDir::AllDirs 0x400 List all directories; i.e. don't apply the filters to directory names.

aurora
3rd May 2012, 12:01
OK ....
I changed filter as follows...still ".."(DotDot) is displaying...
dirmodel->setFilter(QDir::NoDotDot | QDir::Dirs );

Spitfire
8th May 2012, 11:02
There's a bug (https://bugreports.qt-project.org/browse/QTBUG-14760) report about that and it will be fixed in next minor relase.