Regular Expression in QSortFilterProxyModel not working
-
This post is deleted!
-
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"? -
@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 becausepathhave not be loaded indirModelyet?
You can try to connect to the signalQFileSystemModel::directoryLoaded(const QString &path)and confirmpathis loaded, then set the root index of view2
- To solve the filter problem, you need to add
-
- 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 becausepathhave not be loaded indirModelyet?
You can try to connect to the signalQFileSystemModel::directoryLoaded(const QString &path)and confirmpathis loaded, then set the root index of view2
This post is deleted! - To solve the filter problem, you need to add