Right clicking on QHeaderView inside of QTreeView

Posted by taynaron on Stack Overflow See other posts from Stack Overflow or by taynaron
Published on 2010-04-20T07:27:39Z Indexed on 2010/04/20 7:33 UTC
Read the original article Hit count: 428

Filed under:
|
|
|
|

I've written a descendant of QTreeView with multiple columns. I want to create a popup menu that appears whe nthe user right-clicks over the column headers. I have tried catching signals from QTreeView for this, but QTreeView doesn't seem to emit signals on the headers. QTreeView.header() does. I therefore believe I must either:
1: connect one of QHeaderView's signals to a popup function - I have been unable to find a signal that is triggered on a single right click - I have tried sectionClicked, sectionHandleDoubleClicked, sectionDoubleClicked, sectionPressed (not surprised the double click functions didn't catch a single right click - but they do catch a double right click)

self.header().sectionClicked.connect(self.headerMenu)
self.header().sectionHandleDoubleClicked.connect(self.headerMenu)
self.header().sectionDoubleClicked.connect(self.headerMenu)
self.header().sectionPressed.connect(self.headerMenu)

or,
2: write a descendant of QHeaderView with my own MousePressEvent function, and use that for my headers. I have so far been unsuccessful in connecting the new header class to the QTreeView descendant. I keep getting a Segmentation Fault on runtime, with no more explanation.

#in DiceView's init, where DiceHeaders is the QHeaderView descendant
self.setHeader(DiceHeaders())

Any ideas?

© Stack Overflow or respective owner

Related posts about python

Related posts about qt