hi,

i am working with python qt 3.3. And I want a tooltip on a table header.
Here is my code:

#!/usr/bin/python
# -.- coding: utf-8 -.-

import sys
from qt import *
from qttable import *

class HeaderToolTip(QToolTip):
        def __init__(self, header, group=None):
                QToolTip.__init__(self, header, group)
                

        def maybeTip(self, p):
                header = QToolTip.parentWidget(self)
                section = 0
                print header.orientation()
                if header.orientation() == Qt.Horizontal:
                    section = header.sectionAt( header.offset() + p.x() )
                else:
                    section = header.sectionAt( header.offset() + p.y() )

                tipString = header.label( section )
                QToolTip.tip( self, header.sectionRect( section ), tipString )



class MainWidget(QWidget):
        def __init__(self, parent=None):
                QWidget.__init__(self, parent)
                print self
                self.layout = QHBoxLayout(self, 5,5,"layout")
                
                table = QTable(2,2,self, "table")


                HeaderToolTip(table.horizontalHeader())

                t = HeaderToolTip(table.horizontalHeader())


                self.layout.addWidget( table )


        
if __name__=="__main__":
        a = QApplication(sys.argv)              
        w = MainWidget(None)
        table = QTable(5,5,w,"table2")
        w.layout.addWidget(table)
        print w
        t = HeaderToolTip(table.horizontalHeader())
        a.setMainWidget(w)
        w.show()
        a.exec_loop()


The rigth table works, but the left exits with core dump.

jeroen
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to