문제

I use this code.

 QFileSystemModel* fsModel = new QFileSystemModel(this);
 fsModel->setFilter(QDir::NoDotAndDotDot | QDir::Dirs );

I can not understand how to exclude some folders.

도움이 되었습니까?

해결책

Subclassing from a standard model is of course possible, but is considered bad style. You'll gain a nice reusable component by implementing a generic filter proxy model. Inherit from QAbstractProxyModel and implement a filter proxy.

다른 팁

Create a filter model and use your QFileSystemModel as its source.

For your filter, QSortFilterProxyModel has most of what you need - you'll only have to provide a reimplementation of filterAcceptsRow to make the decision of which files should be passed through.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top