[PyQt] QTableView header connection

Mark Summerfield mark at qtrac.eu
Wed Mar 18 15:54:32 GMT 2009


On 2009-03-18, Till Gerken wrote:
> On Wed, Mar 18, 2009 at 3:40 PM, Gert-Jan <gj_den_heijer at hotmail.com> 
wrote:
> > Class GUI:
> >        def __init__(self):
> >                tableWidget = QtGui.QTableWidget()
> >                # Code to insert 5 columns and make a horizontal header)
> >                self.connect(tableWidget.horizontalHeader,
> > QtCore.SIGNAL("clicked()"), self.random_function)
> >
> >        def random_function(self):
> >                print 'ok'
> >
> > However, double-clicking the header does not make the console print 'ok'.

Uh, just off the top of my head (and untested), shouldn't it be:

    self.connect(tableWidget.horizontalHeader(),
	QtCore.SIGNAL("clicked(QModelIndex)"), self.random_function)

or
	QtCore.SIGNAL("doubleClicked(QModelIndex)")

or if you just want to know the column that was clicked

	QtCore.SIGNAL("sectionClicked(int)")

>
> If you double click, the signal should be doubleClicked().
>
> Till
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


-- 
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