Thanks, All. But I think spirit is basic right. It has nothing to do with if the RegExp is correct. The real problem is hierarchical data model. I need to subclass QSortFilterProxyModel to do something concerning "source_parent":
{
protected:
virtual bool MySortFilterProxyModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent
) const{ QFileSystemModel *sm = qobject_cast<QFileSystemModel*>(sourceModel());
if (source_parent == sm->index(sm->rootPath())) {
}
return true;
}
};
class MySortFilterProxyModel : public QSortFilterProxyModel
{
protected:
virtual bool MySortFilterProxyModel::filterAcceptsRow(
int source_row, const QModelIndex &source_parent) const{
QFileSystemModel *sm = qobject_cast<QFileSystemModel*>(sourceModel());
if (source_parent == sm->index(sm->rootPath())) {
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
return true;
}
};
To copy to clipboard, switch view to plain text mode
This works fine for me.
Bookmarks