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?
what coordinate i should set. can you give any small example.
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.
I have checked it but not able to find what is the mistake.
There's not much more I can think of here, sorry. I've never used this function myself.
ok no problem i will try to explore more on that.
You're always displaying the tool tip on entering the widgets area, regardless whether the mouse cursor is in the hot spot or not. So check for the correct position before displaying the tool tip at all.