QWT橡皮筋坐标精度

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 );

}


版权声明:本文为weixin_43577616原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。