Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Hide sidebar in QFileDialog
Qt 6.11 is out! See what's new in the release blog

Hide sidebar in QFileDialog

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 1 Posters 900 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    ducdx
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • D ducdx

      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

      D Offline
      D Offline
      ducdx
      wrote on last edited by
      #2

      Thank all,
      I've resolved it.
      My solution is to find all widgets that I want to hide and hide them. Here is my code

      hide_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()
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved