0

I would like to show a file browser on my PyQt6 Window, and succeeded, but the header shows all columns we could see in a plain windows files explorer (name, type, size, etc.), but I only want the name column to display.

I use QFileSystemModel to display the files, and I don't really know if I should change the header on the QFileSystemModel side or that of the QTreeView.

Here is my code to create the browser:

        model = QFileSystemModel()
        model.setRootPath('C:\\Projects\\Hypertraduction Tool')
        tree = QTreeView()
        tree.setModel(model)
        tree.setRootIndex(model.index('C:\\Projects\\Hypertraduction Tool'))
musicamante
  • 41,230
  • 6
  • 33
  • 58
Zirion
  • 1
  • 1
    `tree.`[`header()`](//doc.qt.io/qt-6/qtreeview.html#header)`.`[`setSectionHidden(column, True)`](//doc.qt.io/qt-6/qheaderview.html#setSectionHidden) – musicamante Jan 23 '22 at 03:11

1 Answers1

0

Thank you for your help musicamante.

I succeed to solve my problem by writing this :

        tree.header().setSectionHidden(1, True)
        tree.header().setSectionHidden(2, True)
        tree.header().setSectionHidden(3, True)
Zirion
  • 1