My system is as follows: python 3.6.0 with PyQt 5.8.1 installed in an anaconda environment on ubuntu 16.10.
I want to show/select network folders (connected via samba) with the PyQt5 FileDialog, but am unable to do so. In PyQt4 (another environment) it works.
relevant code: from PyQt5 import QtWidgets fileDialog=QtWidgets.QFileDialog() workDirectory = str(fileDialog.getExistingDirectory(caption= "Set Work Directory", directory=defaultWorkDirectory)) fileDialog.deleteLater()
The PyQt5 documentation just leads to the C++ one and there is this about network/local files: "Note: The non-native QFileDialog supports only local files." and "When possible, this static function will use the native file dialog and not a QFileDialog. On platforms which don't support selecting remote files, Qt will allow to select only local files." I thought, ubuntu supports this (just like in PyQt4).
Is there a way to do this or do i have to settle with PyQt4?
Thanks, Topsrek
This happens because the gtk3 file dialog hides non-local files by default. (this has to be explicitly enabled in the Qt gtk3 platform implementation, bugreport)
Qt4 doesn’t have gtk3 support so you get a gtk2 file dialog which doesn’t do this.
I didn’t find a way to get Qt5 to use the gtk2 dialog and as you found out yourself the non-native dialog doesn’t support network locations either.
As a workaround you can navigate to already mounted locations in /run/user/(your username)/gvfs/*
.
As ugly as this may seem, I suggest using this instead of going back to PyQt4.