I add search in ListView FolderListModel. For reasons that are not understandable, if the showDirs: true option, nameFilters: [" . "] Does not work. Although the logic should display only directories in which there are matches with the entered values ​​in searchText

ListView { id: dirView model: folderDirModel delegate: folderDeligate FolderListModel { id: folderDirModel sortField: FolderListModel.Name showDirs: true showFiles: false folder: "file:///Users/Directory" nameFilters: ["*.*"] } 

Script

 function updateFilter() { var text = searchField.text var filter = "*" for(var i = 0; i<text.length; i++) filter+= text[i] filter+="*" folderDirModel.nameFilters = [filter] } TextField{ id: searchField onTextChanged: updateFilter() } 

If showFiles: true, showDirs: false. nameFilters works.

  • Maybe someone is also puzzled by this case. In general, the filter for directories is not supported, as the documentation says - Alexander Shadov

1 answer 1

The documentation for the FolderListModel for the nameFilters property specifies:

Directories are not excluded by filters