QWT坐标精度默认是小数点后4位。一大串,很影响界面。有时候我们不需要那么多的位数,可以用如下方法:
继承 qwt_plot_picker.cpp中的 QwtPlotPicker类,重写如下虚函数:
OK!
QwtText QwtPlotPicker::trackerTextF( const QPointF &pos ) const
{
QString text;
switch ( rubberBand() )
{
case HLineRubberBand:
text.sprintf( "%.1f", pos.y() );
break;
case VLineRubberBand:
text.sprintf( "%.1f", pos.x() );
break;
default:
text.sprintf( "%.1f, %.1f", pos.x(), pos.y() );
}
return QwtText( text );
}