Filtering "NoDotDot" in filesystem model not working
-
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 WORKINGdirmodel->setRootPath(sPath); ui->treeView->setModel(dirmodel); ui->treeView->setRootIndex(dirmodel->index(sPath));@
-
Does it work if you replace QDir::AllDirs with QDir::Dirs?
It seems to me that QDir::AllDirs conflicts with QDir::NoDotDot. I'm not entirely sure about that though. -
Qt documentation says:
bq. QDir::AllDirs 0x400 List all directories; i.e. don't apply the filters to directory names.
-
[quote author="Andre" date="1336033688"]Does it work if you replace QDir::AllDirs with QDir::Dirs?
It seems to me that QDir::AllDirs conflicts with QDir::NoDotDot. I'm not entirely sure about that though.[/quote]Ya i tried using as shown below......still it displays ".."(DotDot)
@ dirmodel->setFilter(QDir::Dirs |QDir::NoDotDot);
@ -
Hi,
Try this code.@QString sPath ="c:/";
dirModel = new QFileSystemModel(this);
dirModel->setRootPath(sPath);
dirModel->setFilter(QDir::NoDotDot | QDir::Dirs);
ui->treeView->setModel(dirModel);
ui->treeView->setRootIndex(dirModel->index(sPath));@Its the same as yours. but still works on my system, tested on windows 7.
-
[quote author="Soumitra" date="1336035722"]Hi,
Try this code.@QString sPath ="c:/";
dirModel = new QFileSystemModel(this);
dirModel->setRootPath(sPath);
dirModel->setFilter(QDir::NoDotDot | QDir::Dirs);
ui->treeView->setModel(dirModel);
ui->treeView->setRootIndex(dirModel->index(sPath));@Its the same as yours. but still works on my system, tested on windows 7.
[/quote]Oh thats crazy then....in mysystem its still showing "..", dont know where is the mistake....
-
Could you tell us, what system you're using?
-
[quote author="Andre" date="1336039264"]Could you tell us, what system you're using?[/quote]
its windows 7