hi all,

i m facing a strange problem. i have made a custom toolkit by doing some general drawing. The basic purpose is to show this tooltip when the mouse hovers over a widget and hide it when the cursor is removed off this widget. So, i showed the tooltip when the mouse hovers over the widget and hide it when the mouse is taken off it. Here is the code:
Qt Code:
  1. bool CPreviewLeftWidget::eventFilter(QObject *obj, QEvent *event)
  2. {
  3. if (obj == m_plblIconInfo) {
  4. if (event->type() == QEvent::HoverEnter)
  5. {
  6. CToolTip::showTip(m_plblIconInfo,tr("PreviewLeftWidget_Manual_Positioning_Heading"),tr("PreviewLeftWidget_Manual_Positioning_Tooltip"));
  7. m_bHovered = TRUE;
  8. return true;
  9. }
  10. if(event->type() == QEvent::HoverLeave)
  11. {
  12. CToolTip::onMouseLeave();
  13. m_bHovered = FALSE;
  14. return true;
  15. }
  16.  
  17. else {
  18. // pass the event on to the parent class
  19. return QWidget::eventFilter(obj, event);
  20. }
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 

The problem is that QHoverLeave event is sent even when the mouse is still over the widget...which causes a blinking effect. Here is the showTip and drawing used:
Qt Code:
  1. void CToolTip::showTip(QWidget* widget,QString heading,QString tip)
  2. {
  3. if(m_pGlobalToolTip == NULL )
  4. m_pGlobalToolTip = new CToolTip(widget,heading,tip);
  5.  
  6. m_pGlobalToolTip->setToolTip(heading, tip);
  7.  
  8. if(widget == NULL )
  9. {
  10. return;
  11. }
  12. QRect rect = widget->rect();
  13. QPoint point = widget->mapToGlobal(widget->rect().topLeft());
  14. int rect_height = rect.height();
  15. int rect_width = rect.width();
  16.  
  17. int tooltip_width = m_pGlobalToolTip->getWidth();
  18.  
  19. int xpos;
  20. int ypos;
  21.  
  22. if(m_pGlobalToolTip->isShownOnRight(widget))
  23. {
  24. xpos = point.x() + rect_width + 5 ;
  25. if(xpos < 0)
  26. xpos = 0;
  27.  
  28. ypos = point.y() + (rect_height/2) - 26 - CORNER_RADIUS;
  29. if(ypos < 0)
  30. ypos = 0;
  31. }
  32. else
  33. {
  34. xpos = point.x() - tooltip_width - 5;
  35. if(xpos < 0)
  36. xpos = 0;
  37.  
  38. ypos = point.y() + (rect_height/2) - 26 - CORNER_RADIUS;
  39. if(ypos < 0)
  40. ypos = 0;
  41. }
  42.  
  43.  
  44. QPoint pos(xpos, ypos);
  45. m_pGlobalToolTip->showToolTip(pos);
  46. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. QPainterPath CToolTip::getRoundPath(QRect rc)
  2. {
  3. int x1, y1, x2, y2;
  4. rc.getCoords(&x1, &y1, &x2, &y2);
  5.  
  6. QPainterPath roundPath;
  7.  
  8. if(m_bShowRight)
  9. {
  10. roundPath.moveTo(x2, y1+CORNER_RADIUS);
  11. roundPath.arcTo(x2-CORNER_RADIUS, y1, CORNER_RADIUS, CORNER_RADIUS, 0.0, 90.0);
  12. roundPath.lineTo(x1+CORNER_RADIUS,y1);
  13. roundPath.arcTo(x1+ARROW, y1, CORNER_RADIUS, CORNER_RADIUS, 90.0, 90.0);
  14. roundPath.lineTo(x1+ARROW, y1+20);
  15. roundPath.lineTo(x1, y1+20+6);
  16. roundPath.lineTo(x1+ARROW, y1+20+6+6);
  17. roundPath.lineTo(x1+ARROW, y2-CORNER_RADIUS);
  18. roundPath.arcTo(x1+ARROW, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 180.0, 90.0);
  19. roundPath.lineTo(x1+CORNER_RADIUS, y2);
  20. roundPath.arcTo(x2-CORNER_RADIUS, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 270.0, 90.0);
  21. roundPath.closeSubpath();
  22. }
  23. else
  24. {
  25. roundPath.moveTo(x2-ARROW, y1+CORNER_RADIUS);
  26. roundPath.arcTo(x2-CORNER_RADIUS-ARROW, y1, CORNER_RADIUS, CORNER_RADIUS, 0.0, 90.0);
  27. roundPath.lineTo(x1+CORNER_RADIUS,y1);
  28. roundPath.arcTo(x1, y1, CORNER_RADIUS, CORNER_RADIUS, 90.0, 90.0);
  29. roundPath.lineTo(x1, y2-CORNER_RADIUS);
  30. roundPath.arcTo(x1, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 180.0, 90.0);
  31. roundPath.lineTo(x1+CORNER_RADIUS, y2);
  32. roundPath.arcTo(x2-CORNER_RADIUS-ARROW, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 270.0, 90.0);
  33. roundPath.lineTo(x2-ARROW,y1+20+6+6);
  34. roundPath.lineTo(x2,y1+20+6);
  35. roundPath.lineTo(x2-ARROW,y1+20);
  36. roundPath.lineTo(x2-ARROW,y1+CORNER_RADIUS);
  37. roundPath.closeSubpath();
  38. }
  39.  
  40. return roundPath;
  41. }
To copy to clipboard, switch view to plain text mode 

is this behaviour occuring cuz i do the drawing outside the widget's rectangle which causes QHoverLeave to occur...if this is so, how to stop it . I m on a tight deadline..so i would reallly appreciate a brisk reply or any kind of opinion!!!

Regards,
Amulya