日志
QTreeView中树节点的搜索
2019-05-13 18:46
使用Qt自带例子+QSortFilterProxyModel来实现搜索。
官方介绍:For hierarchical models, the filter is applied recursively to all children. If a parent item doesn't match the filter, none of its children will be shown. 默认情况下QSortFilterProxyModel的Filtering功能,如果父节点不匹配的话,子节点也不会被搜索,这种情况下对绝大多数树的搜索不适用。 不过可以通过重载filterAcceptsRow() 和filterAcceptsColumn()函数来实现,父节点不匹配的话,也会搜索子节点。 |
下一篇: 在模板函数中处理不同类型数据