Using QFileSystemModel's features for arbitrary list of files (not a directory)?
I've created a frontend to the UNIX locate command. Right now I'm just feeding the filenames from locate's output to a QListWidget. From the documentation it seems QFileSystemModel is better suited for displaying filenames (it automatically shows the icons, using a separate thread to get the icons so the main thread doesn't become unrespons开发者_StackOverflow社区ive).
But it seems it only shows files from a certain directory. My files however can be from different directories. Can I add files to QFileSystemModel or does it just show the contents of a single directory?
With QFileSystemModel you can display the whole file system tree if you only set the model to a view. But you're probably using the setRootIndex() func which leaves you with one folder being displayed.
If so you can try:
- to create another folder and there create links to the folders you want. Then use setRootIndex() on the folder you've created. Or just one link in one of the folders pointing to the other one.
- to remove all the model indexes that are of no interest for you
精彩评论