[Qt-interest] What's wrong QDirModel::setNameFilters()?

Lingfa Yang lingfa at brandeis.edu
Thu Mar 11 21:00:41 CET 2010


Hi,

I have a tree view which takes a dir model, showing files in current directory.

    dirModel = new QDirModel;
    treeView.setModel(dirModel);
    treeView.setRootIndex(dirModel->index(QDir::currentPath()));
 
It works fine until:

    dirModel->setNameFilters(QStringList() << "*.h" << "*.cpp"); // ???

Instead of showing expected files on current directory, the tree view shows C: and D: drives only.

Questions:
1) Why setNameFilters() does not filtering files as expected?
1) How can setNameFilters() change the root indexing?

Thanks in advance,
Lingfa



More information about the Qt-interest-old mailing list