PDA

View Full Version : Displaying tooltip for points in the graph



Ankitha Varsha
29th January 2008, 09:33
Hi,

I have been working on Qt3 all this time just started working on Qt4.

in Qt4, I have graphs in my application using Qwt.
I need to display the point values (x and y ) when user keeps the mouse on the points of the curves in the graph as a tooltip.

Qt3 offered QTooltip class which has maybeTip function. I used subclass QToolTip class and re-implement maybeTip function. Then compared the point values captured in maybeTip function and with my curve point values with some tolerence and decided whether I should display tooltip at that position of not.

In Qt4, maybeTip function is removed! :crying:
How can I implement tool tips now in Qt4?

I tried to search this in Qt Assistant, but did not get solid idea :(

Pls help :o

marcel
29th January 2008, 09:42
Doesn't Qwt offer something like that? It should, because this is basic functionality in chart controls.

You could try subclassing the graph widget and carefully override its event() function and handle all events with the type QEvent::ToolTip.

seveninches
29th January 2008, 10:41
It is done through QwtPlotZoomer::trackerText(). Take a look on the qwt-5.0.2/examples/spectrogram example.

Uwe
29th January 2008, 11:49
You need to derive from QwtPlotPicker reimplementing YourPicker::trackerText. Here you have to identify if the current position qualifies as being "over" a point and return the type of information you like.

I already answered this question several times, but unfortunately I couldn't find in which forum it was. So please search on your own, you will find a more detailed discussion and AFAIR some code snippets there.

Uwe

Ankitha Varsha
29th January 2008, 12:08
Hi,
Thank you so much.
I will try it :)