tags:

views:

434

answers:

1

Hi folks,

I'm trying to learn PyQt4 and GUI design with QtDesigner. I've got my basic GUI designed, and I now want to capture when the user clicks on a column header.

My thought is that I need to override QTableWidget, but I don't know how to attach to the signal. Here's my class so far:

class MyTableWidget(QtGui.QTableWidget):
    def __init__(self, parent = None):
        super(MyTableWidget, self).__init__(parent)
        self.connect(self, SIGNAL('itemClicked(QTreeWidgetItem*)'), self.onClick)

    def onClick(self):
        print "Here!"

But, setting a breakpoint in the onClick, nothing is firing.

Can somebody please help me?

TIA Mike

+1  A: 

OK, the SIGNAL needed is:

self.connect(self.horizontalHeader(), SIGNAL('sectionClicked(int)'), self.onClick)
Mike Crowe
Does that solve the problem??? Don't you need to make onClick take self and the int passed by sectionClicked???
mandel
mandel, yes, it appears to. And yes, I did need the int in onClick as well. I was trying to get the signaling working first before implementation.
Mike Crowe