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:Code:
{ if (obj == m_plblIconInfo) { { CToolTip::showTip(m_plblIconInfo,tr("PreviewLeftWidget_Manual_Positioning_Heading"),tr("PreviewLeftWidget_Manual_Positioning_Tooltip")); m_bHovered = TRUE; return true; } { CToolTip::onMouseLeave(); m_bHovered = FALSE; return true; } else { // pass the event on to the parent class } } }
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:
Code:
{ if(m_pGlobalToolTip == NULL ) m_pGlobalToolTip = new CToolTip(widget,heading,tip); m_pGlobalToolTip->setToolTip(heading, tip); if(widget == NULL ) { return; } int rect_height = rect.height(); int rect_width = rect.width(); int tooltip_width = m_pGlobalToolTip->getWidth(); int xpos; int ypos; if(m_pGlobalToolTip->isShownOnRight(widget)) { xpos = point.x() + rect_width + 5 ; if(xpos < 0) xpos = 0; ypos = point.y() + (rect_height/2) - 26 - CORNER_RADIUS; if(ypos < 0) ypos = 0; } else { xpos = point.x() - tooltip_width - 5; if(xpos < 0) xpos = 0; ypos = point.y() + (rect_height/2) - 26 - CORNER_RADIUS; if(ypos < 0) ypos = 0; } m_pGlobalToolTip->showToolTip(pos); }
Code:
{ int x1, y1, x2, y2; rc.getCoords(&x1, &y1, &x2, &y2); QPainterPath roundPath; if(m_bShowRight) { roundPath.moveTo(x2, y1+CORNER_RADIUS); roundPath.arcTo(x2-CORNER_RADIUS, y1, CORNER_RADIUS, CORNER_RADIUS, 0.0, 90.0); roundPath.lineTo(x1+CORNER_RADIUS,y1); roundPath.arcTo(x1+ARROW, y1, CORNER_RADIUS, CORNER_RADIUS, 90.0, 90.0); roundPath.lineTo(x1+ARROW, y1+20); roundPath.lineTo(x1, y1+20+6); roundPath.lineTo(x1+ARROW, y1+20+6+6); roundPath.lineTo(x1+ARROW, y2-CORNER_RADIUS); roundPath.arcTo(x1+ARROW, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 180.0, 90.0); roundPath.lineTo(x1+CORNER_RADIUS, y2); roundPath.arcTo(x2-CORNER_RADIUS, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 270.0, 90.0); roundPath.closeSubpath(); } else { roundPath.moveTo(x2-ARROW, y1+CORNER_RADIUS); roundPath.arcTo(x2-CORNER_RADIUS-ARROW, y1, CORNER_RADIUS, CORNER_RADIUS, 0.0, 90.0); roundPath.lineTo(x1+CORNER_RADIUS,y1); roundPath.arcTo(x1, y1, CORNER_RADIUS, CORNER_RADIUS, 90.0, 90.0); roundPath.lineTo(x1, y2-CORNER_RADIUS); roundPath.arcTo(x1, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 180.0, 90.0); roundPath.lineTo(x1+CORNER_RADIUS, y2); roundPath.arcTo(x2-CORNER_RADIUS-ARROW, y2-CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, 270.0, 90.0); roundPath.lineTo(x2-ARROW,y1+20+6+6); roundPath.lineTo(x2,y1+20+6); roundPath.lineTo(x2-ARROW,y1+20); roundPath.lineTo(x2-ARROW,y1+CORNER_RADIUS); roundPath.closeSubpath(); } return roundPath; }
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