Regular Expression in QSortFilterProxyModel not working
Unsolved
General and Desktop
-
This post is deleted!
-
@Thomas-Stein said in Regular Expression in QSortFilterProxyModel not working:
proxyModel.setFilterRegExp("*.png")
Looks like a file wildcard, not a reg exp. That demands literal
*
character. Don't you intend perhaps:".*\\.png"
? -
This post is deleted!
-
- To solve the filter problem, you need to add
proxyModel.setRecursiveFilteringEnabled(true)
.
Otherwise you'll only filter the drivers. - If you only want to filter with wildcard, simply use
proxyModel.setFilterWildcard("*.png")
instead of regular expression. - The root index of view2 won't be at
path
, becauseproxyModel.mapFromSource(dirModel.index(path))
will return an invalid index.
Maybe becausepath
have not be loaded indirModel
yet?
You can try to connect to the signalQFileSystemModel::directoryLoaded(const QString &path)
and confirmpath
is loaded, then set the root index of view2
- To solve the filter problem, you need to add
-
This post is deleted!