Printing Values of the mouse position in a graph
I have a graph with X and Y scale of (0-100, 0-100), the graph is simple sine function. I want to get the values of the axis point, where the mouse button is clicked. I am able to get the widget mouse position, but not able to get the actual graph position values(the sine function values).
Is it possible to get the values ?? is it possible to display those values as a tooltip ???
Thanks in advance .......
Re: Printing Values of the mouse position in a graph
Re: Printing Values of the mouse position in a graph
Code:
{
{
const QwtDoublePoint p = invTransform(pos);
const QwtDoublePoint curvePos(p.x(), ::sin(p.x());
if ( qAbs(pos.y() - transform(curvePos).y() ) < 4 )
text.sprintf("%.4f, %.4f", curvePos.x(), curvePos.y());
return text;
}
};
Then use your picker like in the bode or like in the spectrogram example.
HTH,
Uwe
Re: Printing Values of the mouse position in a graph
Hi Uwe ...
Actually I put the sin function as an example, I just want to display the values where ever (on the curve) the mouse is clicked, how it is possible ..... is it possible to display those value as a mouse tool tip ???
Re: Printing Values of the mouse position in a graph
Quote:
Actually I put the sin function as an example, I just want to display the values where ever (on the curve) the mouse is clicked, how it is possible .....
Replace the code by something that finds the next point in your data. You can try to use QwtPlotCurve::closestPoint(), but this implementation is slow for many points. Then you will need something spatial indexed like a quadtree.
Quote:
is it possible to display those value as a mouse tool tip ???
What about reading the answers you already got ?
Uwe