Hello everyone,
I have a QwtSymbol on plot and i want to display like a tool-tip for each symbol i have on the curve, when i click on the symbol.
so how can i attache like a tool-tip to display the info i need ??
Thanks
Hello everyone,
I have a QwtSymbol on plot and i want to display like a tool-tip for each symbol i have on the curve, when i click on the symbol.
so how can i attache like a tool-tip to display the info i need ??
Thanks
You can use QwtPlotPicker overloading trackerText(). How to identify which click is a match of which symbol and how to connect a match to the information you want to display is up the the application code.
Maybe the ( slow ! ) implementation of CanvasPicker::select in the event_filter example is something you can use. When the symbols are from curves with an ordered set of points you might want to use qwtUpperSampleIndex you can find in qwt_series_data.h in SVN trunk.
Uwe
Thanks,
Regarding how i identify the symbols, i used the event_filter example.
but there is an issue i faced which, when i have other curve that does NOT have symbols, and i click close to one of its points the application crashes. i know because it expects a symbol and didn't find it, but how can i fix this issue, so what would be my if statements to check if the curve has a symbol or not ?? hope you got what i am trying to explain.
how i connect the information to the symbol, I save the information i want to display with each symbol in the same order i draw the symbol an with that the symbol index is my index for the information.
thanks
Qt Code:
if(curve->symbol()) { // curve has a symbol } else { // curve doesn't have a symbol }To copy to clipboard, switch view to plain text mode
Yeah i tried this and its crashed as well,
so what i did is if (d_selectedCurve->style()== QwtPlotCurve::Lines) as in my case the curves that has symbols are a noline style. this worked for me.
Thank you so much Wysota
but this method only got called when we get a point on a curve with its index.
But it is you who initializes this variable. Maybe you did it incorrectly. Did you use d_selectedCurve->symbol() or something else?
yes i did used it. i almost used the same code in the example i only added thing i need. but the method and detecting the symbol is same as the example.
so maybe u can just add a curve with no symbols in the example and see that.
I can only repeat myself: use a combination of QwtPlotPicker and QwtPlotCurve::closestPoint() ( or something faster depending on the characteristics of your curve ).
Copying code from an unrelated example instead of trying to understand what needs to be done is nothing but a waste of time.
Uwe
My main problem was not detection the symbols on the curve or how to related the information to the selected symbol, and this is clear from my question which is tooltip for symbols.
you suggested this example too, in "CanvasPicker::select in the event_filter example is something you can use".
I do have the information displayed in a fixed label when i click the symbol. but I was wording if there a way to display a kinda tool-tip to symbols.
you suggested overloading trackerText(),
I was thinking of using QwtPlotMarker
i tired something like :
but the text keep showing on (0,0) coordinates. I do not know what is the wrong im doing.Qt Code:
t->setText("Test"); m->setLabel(*t); m->attach(myplot); m->setAxes(4000,1000);To copy to clipboard, switch view to plain text mode
or how i show the marker in the position/coordinates I want to.
I'm doing something like this. I have a plot picker set up with tracking machine that keeps track of the position of the cursor in plot coordinate space. Then I'm handling help events on the plot to show a tooltip based on the data from the picker if the closest point in the curve is close enough to the cursor (i.e. manhattan length <= some constant in pixels).
Can you please explain more...
what are the help events ??
The tooltip you are showing ?? are you using Tracker Text and qwttext ?? or what exactly u r using ??
the other thing how can i show the marker in plot coordinate, if you saw the example i put in the previous reply ??
Thank you soo much.
QHelpEvent
QToolTip::showText()The tooltip you are showing ?? are you using Tracker Text and qwttext ?? or what exactly u r using ??
If you use a real marker then the downside is that the plot has to be replot each time you want to change the marker position (provided you don't want to mess up with the way the plot is rendered). A better way is to draw the marker on a separate layer (e.g. using an overlay widget) which doesn't influence the plot itself.the other thing how can i show the marker in plot coordinate, if you saw the example i put in the previous reply ??
Instead of using a tooltip it is also possible to overload trackerText and simply return an empty text, when the position is too far away and a valid text otherwise. As a QwtText might have a background and a frame it doesn't look too different from a tooltip.
For a combination of QwtPickerClickPointMachine and the tracker mode set to QwtPicker::ActiveOnly the trackerText() hook will only be called for mouse clicks - if this is what is requested.
Uwe
PS: sooner or later I will offer an implementation of some spatial ordering ( f.e. a quadtree ) to speed up this use case for curves with many points
Bookmarks