QFileSystemModel doesn't support the network paths and external drives?
-
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:
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?
NOTE I also asked this question on Stack Overflow, here:
https://stackoverflow.com/questions/59689177/qt-qfilesystemmodel-doesnt-support-the-network-paths-and-external-drives -
In the docs it's says that the model is for a local filesystem. So i don't think you can show network directories with it.
I think the easiest way is to write your own file system model.
-
Hi
On win 10, it shows
Mounted USB and Mounted network shares. ( connect to a drive letter )How, it wont show phones, or the NetWork object.
NTPASS is usb stick and data (Z) is a mounted network share
-
@beecksche said in QFileSystemModel doesn't support the network paths and external drives?:
I think the easiest way is to write your own file system model.
Or, presumably extend
QFileSystemModel
by subclassing it.@jeanmilost
I just don't think you can access network, as per https://stackoverflow.com/a/33856139/489865 and @beecksche's comment above.