They were broken with the Qt 4.x port. See patch attached. I am not sure
if the column number is calculated right.

Please review it ;-) I am not sure if it is the right way to do custom
tooltips in Qt 4.x

Duncan
Index: src/QY2ListView.cc
===================================================================
--- src/QY2ListView.cc	(revision 53560)
+++ src/QY2ListView.cc	(working copy)
@@ -37,19 +37,19 @@
     , _mouseButton1PressedInHeader( false )
     , _finalSizeChangeExpected( false )
 {
-    //FIXME QTreeWidget::setShowToolTips( false );
     setRootIsDecorated(false);
 
-#if FIXME_TOOLTIP
-    _toolTip = new QY2ListViewToolTip( this );
-#endif
-
     if ( header() )
     {
 	header()->installEventFilter( this );
 	header()->setStretchLastSection( false );
     }
 
+    // install a
+    if ( viewport() )
+        viewport()->installEventFilter(this);
+    
+
     connect( header(),	SIGNAL( sectionResized     ( int, int, int ) ),
 	     this,	SLOT  ( columnWidthChanged ( int, int, int ) ) );
 
@@ -64,10 +64,6 @@
 
 QY2ListView::~QY2ListView()
 {
-#if FIXME_TOOLTIP
-    if ( _toolTip )
-	delete _toolTip;
-#endif
 }
 
 
@@ -303,10 +299,10 @@
 #endif
 }
 
-
 bool
 QY2ListView::eventFilter( QObject * obj, QEvent * event )
 {
+    // this handles events in the header
     if ( event && obj && obj == header() )
     {
 	if ( event->type() == QEvent::MouseButtonPress )
@@ -331,6 +327,28 @@
 	}
     }
 
+    // handle a tooltip event
+    // we need first to figure out which column was the one
+    // mouse-overed
+    if (event->type() == QEvent::ToolTip && obj != header() )
+    {
+         QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
+         // which item?
+         QTreeWidgetItem *item = itemAt(helpEvent->pos());
+
+         if (item)
+         {
+             // now figure out the column
+             int column = columnAt(helpEvent->x());
+             QToolTip::showText(helpEvent->globalPos(), toolTip(item, column));
+         }
+         else
+         {
+             QToolTip::hideText();
+         }
+     }
+
+
     return QTreeWidget::eventFilter( obj, event );
 }
 
Index: src/QY2ListView.h
===================================================================
--- src/QY2ListView.h	(revision 53560)
+++ src/QY2ListView.h	(working copy)
@@ -160,7 +160,6 @@
      **/
     virtual bool eventFilter( QObject * obj, QEvent * event );
 
-
 protected slots:
 
     /**
@@ -182,7 +181,6 @@
 
 
 protected:
-
     /**
      * Handle mouse clicks.
      * Reimplemented from QScrollView.

Reply via email to