[PyQt] QTableWidget: cannot alter text of header labels

Nick Gaens mail at nickgaens.com
Thu May 20 20:56:55 BST 2010


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

self.tw.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem("b")) # Doesn't
> work, the header label isn't updated to "b"



- Attempt 2:

twi = QtGui.QTableWidgetItem("b")

self.tw.setHorizontalHeaderItem(1, twi)

self.tw.horizontalHeader().setVisible(True) # Nope, this doesn't work either



- Attempt 3:

twi = QtGui.QTableWidgetItem()

self.tw.setHorizontalHeaderItem(1, twi)

self.tw.horizontalHeader().setVisible(True) # Nope, this doesn't work
> either

_twi = self.tw.horizontalHeaderItem(1)

_twi.setText("b") # Nope, doesn't get updated by this either..



What am I doing wrong? How much more combinations of horizontalHeader-stuff
do I have to try in order to do this simple thing?


-- 
Nick Gaens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100520/27afe01e/attachment.html>


More information about the PyQt mailing list