Hello!
I have curve built by 100 points, how can i add tool tip with x and y to this points
I try to use qwt symbol for this goal, but there is not method setToolTip
In advance many thanks for your help!
Printable View
Hello!
I have curve built by 100 points, how can i add tool tip with x and y to this points
I try to use qwt symbol for this goal, but there is not method setToolTip
In advance many thanks for your help!
You can use QwtPlotPicker with QwtPicker::AlwaysOn to display text as you traverse the graph. See examples too.
i need to see coordinates not all the time, i need to see it if mouse moved near some point
I know, that i can redefine mouse move event in qwt symbolm but there no more easy way?
No you can't - QwtSymbol is no QWidget.
Instead you can follow the hint of pkj using a customized picker:
Code:
{ .... { double dist = 10e10; int index = -1; const QwtPlotItemList& itmList = plot()->itemList(); for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { { double d; int idx = c->closestPoint( pos, &d ); if ( d < dist ) { curve = c; index = idx; dist = d; } } } QString text; const int maxPixels = 10; if ( dist < maxPixels ) { text.sprintf( "%.4f, %.4f", pos.x(), pos.y() ); } } };
QwtPlotCurve::closestPoint() iterates over all points what might be too slow for many points. If can implement something faster using the characteristics of your samples ( f.e when they have increasing x values ) better implement it. In the worst case you need to introduce some spatial organized index like a quadtree.
Uwe
Thank you for your help!
Added after 50 minutes:
Oh, function clossestPoint() dont work right!
//http://hostingkartinok.com/image/01201110/54dfa7b8bb51489265f5c2141a17a7df.jpg
For example look at this
http://hostingkartinok.com/image/012...947e6bc613.jpg
I checked: in the higher point distance is bigger, even if the cursor directly on the chart