I create my own dialog with the file using the following code:
file_dialog = QtGui.QFileDialog() file_dialog.setFileMode(QtGui.QFileDialog.Directory) file_dialog.setViewMode(QtGui.QFileDialog.Detail) file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog, True)
The behavior that interests me is that the user can view files and folders, but only select folders. (making files inaccessible). Is it possible?
Note: Using the DirectoryOnly parameter is not suitable for me, because it does not allow viewing files, just folders.
Edit (additional code that I forgot to add, which is responsible for the ability to select multiple folders instead of one):
file_view = file_dialog.findChild(QtGui.QListView, 'listView') if file_view: file_view.setSelectionMode(QtGui.QAbstractItemView.MultiSelection) f_tree_view = file_dialog.findChild(QtGui.QTreeView) if f_tree_view: f_tree_view.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
source share