What may be the error in the following function?
-
@void of_tooltip::enterEvent (QEvent *e)
{QToolTip::showText (this->pos ()+QPoint(70,80), "text",this,QRect(0,0,50,50)); QPushButton::enterEvent (e);
}
@
Here i want to display tooltip when mouse enter the provided rect(0,0,50,50) area of button but the problem i am getting here is when mouse enter the area of button which are not under rect the tooltip is displaying and suddenly hiding.Actually in this area which are not under rect the tooltip should not be display then why it is showing and hiding? -
Can't you use the standard toolTip for QPushButton?
From QToolTip documentation:
[quote]Shows text as a tool tip, with the global position pos as the point of interest. The tool tip will be shown with a platform specific offset from this point of interest.
If you specify a non-empty rect the tip will be hidden as soon as you move your cursor out of this area.
The rect is in the coordinates of the widget you specify with w. If the rect is not empty you must specify a widget. Otherwise this argument can be 0 but it is used to determine the appropriate screen on multi-head systems.[/quote]I guess you might be assuming different coordinates than this function. The first argument is in global coordinate system, the other one in local. Maybe that's the problem here?
-
I'd say you could experiment to verify which points point where.
For a start, try calling:
@
QToolTip::showText (this->pos() + QPoint(70, 80), "text", this);
@Which is the same statement, but without the QRect. You could also test some changes to "QPoint" part.
-
There's not much more I can think of here, sorry. I've never used this function myself.