[PyQt] [QTtableWidget] detect click on column header?

Lara Michaels laramichaels1978 at yahoo.com
Sat Feb 20 23:44:52 GMT 2010


My apologies, I have figured out that I need to listen to the QHeaderView's sectionClicked(int) signal.

But I am still stuck. How do I override the function that normally does the sorting? I tried subclassing from QTableWidget and reimplementing sortByColumn(), but my function never gets called:

class MyQTableWidget(QTableWidget):

   def sortByColumn(self, col, order): 
       print 'called!'


What am I doing wrong to implement my own sortByColumn?

Many thanks for any advice

lara

--- On Sat, 2/20/10, Lara Michaels <laramichaels1978 at yahoo.com> wrote:

> From: Lara Michaels <laramichaels1978 at yahoo.com>
> Subject: [PyQt] [QTtableWidget] detect click on column header?
> To: pyqt at riverbankcomputing.com
> Date: Saturday, February 20, 2010, 11:06 PM
> Hello,
> 
> I am trying to allow items in a QTableWidget to be sorted
> by date. Difficulty: I want to display the date to the user
> in a human-friendly way, yet be able to sort on that
> column.
> 
> What I have done is I have created a hidden column with a
> UNIX timestamp corresponding to that date, on which
> lexicographic sorting will generate the correct results. I
> need your help with the following:
> 
> - how can I intercept a click on a(n horizontal) header of
> a QTableWidget? I have tried defining its mousePressEvent()
> method, but it does not get called when the user clicks on a
> *header* (it does when the user clicks on a normal cell).
> 
> Many thanks for any help
> 
> lara
> 
> 
>       
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 


      



More information about the PyQt mailing list