QFileSystemModel doesn't support the network paths and external drives?
-
wrote on 14 Jan 2020, 16:23 last edited by
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 -
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-driveswrote on 14 Jan 2020, 18:02 last edited byIn 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.
-
-
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.
wrote on 14 Jan 2020, 18:21 last edited by JonB@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.
4/4