0

Using Qt (Qt 5.13 more precisely), I want to create a file browser, as closest as possible as the Windows Explorer one. This file browser should be as simple as possible from the point of view of code, but as complete as possible from the point of view of the functionalities.

I found that a QFileSystemModel model exists, and combined with a view, it may be used as a base for create my explorer. However I faced several serious limitations using this model. One of the most annoying is that I could found no option to show the external drives (USB drives, connected phones, ...) and the network paths (Neighbor network, ...). Setting the model to the root, I can see all my local drives, including the virtual ones (i.e those mounted with the subst command), but nothing else.

I use this code to create my model and link it to a view on my interface:

QFileSystemModel* pModel = new QFileSystemModel;
pModel->setRootPath(pModel->myComputer().toString());
ui.treeView->setModel(pModel);

And I get this result:

enter image description here

The 4 first entries are physical drives, and the 4 last are virtual drives. But I cannot show nothing else, despite of all my retries to configure the model.

How should I change the above code to also see the network and external drives?

Jean-Milost Reymond
  • 1,833
  • 1
  • 15
  • 36
  • 1
    Have you checked QStorageInfo::fileSystemType()? – Ali Hosseini Nezhad Jan 14 '20 at 07:30
  • 1
    @Ali Thank you for the suggestion. I tried to get the root (`QStorageInfo::root()`) and to iterate through the mounted volumes (`foreach (const QStorageInfo& storage, QStorageInfo::mountedVolumes())`). The Qt doc says that this should list the same content as shown in the "My Computer" dir, however the result gives the exact same list as above. No network drives nor external ones. Is something wrong in my Qt config? – Jean-Milost Reymond Jan 14 '20 at 14:00
  • 1
    I don't think you can do any network, as per https://stackoverflow.com/a/33856139/489865 – JonBrave Jan 14 '20 at 18:34
  • 1
    Except of mapped network drive: `foreach(QStorageInfo i, QStorageInfo::mountedVolumes()){ qDebug() << i.device() << "(" << i.rootPath() << ")";}` – Ali Hosseini Nezhad Jan 15 '20 at 12:10

0 Answers0