How do I properly deal with the QHeaderView of a QTreeWidget (it always displays "1" )



  • Here's a screenshot:
    0_1501550413133_Untitled.png

    In which I tried to change its label:

    class HeaderView(QHeaderView):
        def __init__(self):
            super().__init__(Qt.Horizontal)
            #self.setContentsMargins(0, 0, 0, 0)
            self.setLayout(QGridLayout())
            self.layout().addWidget(QLabel("blah"), 0, 0)
    
    class EventsWidget(QDockWidget, Ui_EventsWidget):
        def __init__(self):
            super().__init__()
            super().__init__()
            self.setupUi(self)
        
            self.tree.setHeader(HeaderView())
    

    to no avail. How do you work with QTreeWidgets? How do I "get rid" of the "1"? Ideally I want a vertical list of ">"s (the default) but already expanded, without the "1" there. I also don't want a header of column labels.



  • This seems to work and I am still able to add items (they show up):

    self.tree.header().setHidden(True)
    


  • The contents of the QHeaderView are controlled by the model treeWidget.model().setHeaderData(/**/);


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.