Hide sidebar in QFileDialog
Solved
Qt for Python
-
Dear all,
I create a desktop application using PyQt5 (run on Ubuntu). In the app, I use QFileDialog in order to select a file in a specific folder. I have done to open my folder to select a file (I've set the option DontUseNativeDialog), but I want to hide the sidebar in order for the user cannot to change the folder. I've searched but still have not found any solution. Could you give me some advice?
Thank you very much -
Thank all,
I've resolved it.
My solution is to find all widgets that I want to hide and hide them. Here is my codehide_widget_name = ["sidebar", "lookInLabel", "lookInCombo", "backButton", "forwardButton","toParentButton", "newFolderButton", "listModeButton", "detailModeButton"] options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fd = QFileDialog(self, title, folder_name, filter) fd.setOptions(options) fd.setAcceptMode(QFileDialog.AcceptOpen) views = fd.findChildren(QWidget) for obj in views: obj_name = obj.objectName() if obj_name in hide_widget_name: obj.hide() fd.fileSelected.connect(self.on_file_selected) fd.exec()