[PyQt] QTableWidget: cannot alter text of header labels

Mark Summerfield list at qtrac.plus.com
Fri May 21 12:04:34 BST 2010


On 2010-05-20, Nick Gaens wrote:
> Hello PyQt,
> 
> I'm wondering why I can't change the text that's displayed in the
>  horizontal or vertical header of my standard QTableWidget.
> 
> - Constructor and simple count specification
> 
> self.tw = QtGui.QTableWidget()
> 
> self.tw.setColumnCount(5)
> 
> - Attempt 1:
> > self.tw.setHorizontalHeaderLabels(("a", "b", "c", "d", "e")) # Doesn't
> > work, the default "1" ... "5" are still shown

Try passing a list not a tuple, i.e.,

    self.tw.setHorizontalHeaderLabels(["a", "b", "c", "d", "e"])
    # works for me


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Rapid GUI Programming with Python and Qt" - ISBN 0132354187


More information about the PyQt mailing list