Using QFileSystemModel's features for arbitrary list of files (not a directory)?

603 views Asked by At

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 unresponsive).

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?

1

There are 1 answers

0
zkunov On

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