0

I have to do a file manager where I can rename, delete, copy files to a remote location (that part is finished) etc.. I think I need QFile and QDir to get the local side of the manager to work with the remote side. QFileSystemModel looks like an easy way to show the local files and folders. But how can I get the selected/clicked item in QFileSystemModel? And what are those items, are they QFiles and QDirs or something else? If they are something else, is there a way to get the QFile and QDir objects somehow?

I'm new to Qt so I don't actually know anything from it. I'm just told to this thing as a homework. Sadly I haven't been given enough education about it and even the assistant assigned to help me can't help with this :/ Any advice how to create a view for local files where the items are easy to get, are greatly appreciated. Thank you!

Masza
  • 331
  • 1
  • 3
  • 12

1 Answers1

0

You misunderstood Qt MVC. Selection - is part of view, not of a model. Check: selection model or selected indexes.

Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61
  • I forgot to mention that I already tried QSelectionModel. With that I'm able to get filenames and filepaths. But it seems to me that that's it. – Masza Apr 28 '15 at 22:32
  • And that's all there is. What else do you want? With filenames and filepaths you can create your QFile and QDir objects if necessary. – Greenflow Apr 28 '15 at 22:34
  • So, the constructor of QFile or QDir accepts a complete file path also? Let's say, like `/home/user/documents/text.pdf` – Masza Apr 28 '15 at 22:38
  • Of course :-) Though QDir probably only /home/user/documents – Greenflow Apr 28 '15 at 22:49
  • ...yes it seems to accept. I also confused real files and QFiles... of course QFile must be created I want to use one... :-) – Masza Apr 28 '15 at 22:49