PDA

View Full Version : Tool Tip



Rakesh_Kumar
29th September 2008, 12:15
Hi all,

I am usuing the toolTip() function for displaying the tool tip. The tool tip disappears after some seconds. My requirement is "As long as the mouse is at that location that tool tip should be displayed." After the mouse moved from that location, the tool tip should goes away.

Could any one please help me for implementing this?

Thanks a lot in advance.
:D
Thanks and Regards
Rakesh lenka

aamer4yu
29th September 2008, 14:42
Well, am not sure if any Application setting can be modified to achieve this.

But you can do this -
Inherit QToolTip, or make a new class , reimplement the mouse events.
Next step is to install a event filter on the QApplication, and catch QEvent::tooltip ( am not sure if its exactly same). And when u catch the event, show your tooltip class instead of the QTooltip.
You can close the custom tooltip on focusoutEvent.
Hope this helps u :)

Rakesh_Kumar
30th September 2008, 04:59
Hi,

Thanks a lot for your response. I am new to Qt. I am not sure how to install a event filter on the QApplication, and catch QEvent::tooltip .Could you please elaborate more or can give a sample code .

Thanks and Regards
Rakesh

aamer4yu
30th September 2008, 07:34
EVen if u are new, I guess u might have noticed the Search page ;)
You can many related threads,, (ex 1 (http://www.qtcentre.org/forum/f-qt-programming-2/t-extended-tooltip-14991.html), ex 2 (http://www.qtcentre.org/forum/f-qt-programming-2/t-tooltip-8341.html) )

Rakesh_Kumar
30th September 2008, 12:38
Hi Aamer,

Thanks a lot. Now I got to know how to install an event filter on the QApplication. But I am not able to find which mouse events has to be reimplemented in the new Tool tip class. Could you please provide some help for this as well.

Regards,
Rakesh

aamer4yu
1st October 2008, 11:46
I dont think you need to work on mouse move events,
In the filter you will get a QEvent::ToolTip event. catch it and show ur tooltip widget.
In the custom tooltip widget, reimplement focusOut event and close the widget on focusout.

Hope u get the idea :)

Rakesh_Kumar
3rd October 2008, 08:51
Hi Aamer,

Thanks a lot. I am having lot of tool tips in my application. It's really tedious to implement lot of widgets for those.

I have one more idea. There is an attribute Qt::WA_AlwaysShowToolTips. Can we use that? I tried that with my buttons, It's not working.

static bool on = true;
m_FastBackwardButton->setAttribute(Qt::WA_AlwaysShowToolTips, on);

This is for my testing purpose.Latter on I will make the on event true and false depending on the mousehover event. This is not working.

Could you please let me know if there is anything wrong.

Thanks and Regards
Rakesh Lenka

jpn
3rd October 2008, 11:54
Did you read the documentation of Qt::WA_AlwaysShowToolTips? It doesn't change the duration tooltips are visible, but enables tooltips for inactive windows.

Rakesh_Kumar
3rd October 2008, 12:23
Hi JPN,

Thanks a lot for your response. You are right. WA_AlwaysShowToolTips enables tooltips for inactive windows. I was wrong.

Is there any other easier way to change the duration of tool tips without implementing custom widgets for each of the tool tips.

Thanks and regards,
Rakesh Lenka

jpn
3rd October 2008, 14:01
Is there any other easier way to change the duration of tool tips without implementing custom widgets for each of the tool tips.
QToolTip implementation uses hard coded values. So, currently the only way is to modify Qt sources. You can try to send a suggestion to make it adjustable, though. :)