PDA

View Full Version : Labels on axis.



eugene
3rd August 2010, 06:33
Hello. How I can change frequency of labels drawning on axis? (Example in attachment)

KosyakOFF
5th August 2010, 11:28
I think that you should set your own scalediv with your own ticks. As far as I know visble values of scale are - majorTicks. So majorTick values should be [1,2,3,4...] and minorTicks - [0.5,1.5,...]

eugene
6th August 2010, 09:41
I tried this code, but has no effect. What do I wrong?


QwtScaleDiv scaleDiv;
QwtValueList vList;
vList<<1<<2<<3<<4<<5;
scaleDiv.setTicks(QwtScaleDiv::MajorTick,vList);
setAxisScaleDiv(xBottom,scaleDiv);

Uwe
6th August 2010, 11:54
I tried this code, but has no effect. What do I wrong?
A QwtScaleDiv is more than its ticks - at least you have to set a valid interval.
The rest of this code snippet looks o.k. for me.

Uwe

eugene
6th August 2010, 12:29
How I can get this intervals and set they? I cant understand this, because documentation of Qwt very poor, and I don't have any examples about this. I tried code from this topic http://www.qtcentre.org/threads/32545-scale-widget-with-major-tick-in-the-middle but also has no effect.

Uwe
6th August 2010, 13:30
How I can get this intervals ...
Maybe [1-5], but what do I ( or anybody else beside you ) know about the interval you want to have displayed on your axis ?

... and set they?
QwtScaleDiv::setInterval(). The docs might be weak, but ...

I cant understand this, because documentation of Qwt very poor, ... QwtScaleDiv stores the min/max values of a scale and the positions of its ticks. What else needs to be understood ?

But is setting the ticks manually really what you want you to do - I guess instead you want to use the scale engine that is responsible for calculating the ticks configured, so that you get major ticks at each integer number: for this you have to play with the step parameter in QwtPlot::setAxisScale or with QwtPlot::setAxisMaxMajor().

Uwe