Interval and all tick positions of a scale are stored in a QwtScaleDiv object.
You can manually create a QwtScaleDiv and assign it to a plot axis (QwtPlot::setAxisScaleDiv()) , or you can use a QwtScaleEngine ( QwtPlot has one for each axis), that calculates it for you. When autoscaling ( QwtPlot::setAxisAutoScale() ) is enabled, the interval for the calculation of the scale is taken from the bounding rectangle of the plot items ( f.e. curves ), otherwise interval/step size are passed with QwtPlot::setAxisScale().
The default scale engines try to calculate ticks for linear decimal scales, what doesn't need to be the right thing for date/time scales. ( QwtDateTimeScaleEngine is on my TODO list ). To improve your scale divisions you can derive and assign ( QwtPlot::setAxisScaleEngine()) your own scale engine or simply use QwtPlot::setAxisScaleDiv instead.
You can manually create a QwtScaleDiv and assign it to a plot axis (QwtPlot::setAxisScaleDiv()) , or you can use a QwtScaleEngine ( QwtPlot has one for each axis), that calculates it for you. When autoscaling ( QwtPlot::setAxisAutoScale() ) is enabled, the interval for the calculation of the scale is taken from the bounding rectangle of the plot items ( f.e. curves ), otherwise interval/step size are passed with QwtPlot::setAxisScale().
The default scale engines try to calculate ticks for linear decimal scales, what doesn't need to be the right thing for date/time scales. ( QwtDateTimeScaleEngine is on my TODO list ). To improve your scale divisions you can derive and assign ( QwtPlot::setAxisScaleEngine()) your own scale engine or simply use QwtPlot::setAxisScaleDiv instead.

博客内容讲述了如何在Qwt库中自定义坐标轴的刻度(ticks),特别是针对x轴的时间显示。通过TimeScaleDraw::label()方法将时间戳转换为易读的时间字符串,实现横坐标位置的定制。同时,需要重载QwtText的label函数来改变具体的刻度值。在主函数中进行相应调用以完成自定义设置。
最低0.47元/天 解锁文章
1152





