
Originally Posted by
davey
For the implementation of trackerText(), all I need is to return a text with both Y axes value but the problem is how.
You can use the canvas maps:
virtual QwtText YourPicker
::trackerText(const QwtDoublePoint
&pos
) const {
double y2 = plot()->canvasMap(axis).invTransform(p.y());
...
}
virtual QwtText YourPicker::trackerText(const QwtDoublePoint &pos) const
{
QPointF p = transform(pos);
int axis = (yAxis() == QwtPlot::yRight) ? QwtPlot::yLeft : QwtPlot::yRight:
double y2 = plot()->canvasMap(axis).invTransform(p.y());
...
}
To copy to clipboard, switch view to plain text mode
In your special situation, where you simple append the second y value to the text you could also do the following:
{
double y2 = plot()->canvasMap(axis).transform(p.y());
text += ...
return text:
}
virtual QwtText YourPicker::trackerText(const QPoint &pos) const
{
int axis = (yAxis() == QwtPlot::yRight) ? QwtPlot::yLeft : QwtPlot::yRight:
double y2 = plot()->canvasMap(axis).transform(p.y());
QwtText text = QwtPlotPicker::trackerText(pos);
text += ...
return text:
}
To copy to clipboard, switch view to plain text mode
Uwe
Bookmarks