Hi all,
is there a way to know the distance in pixels between two ticks?
Thank you very much for your help!
Hi all,
is there a way to know the distance in pixels between two ticks?
Thank you very much for your help!
With plot->axisScaleDiv(...) you find the list of all ticks. With plot_canvasMap(...) you can translate them into pixel positions.
Uwe
kalos80 (20th October 2008)
Uwe, thank you very much for your hints.
Could anyone please expand on this? I can't understand how to use the QwtScaleMap object to perform said conversion.
Qt Code:
int distance_in_pixels = scaleMap->transform( xTick2 ) - scaleMap->transform( xTick1 );To copy to clipboard, switch view to plain text mode
(From Qwt 5.2; may be different in 6.0 but probably not).
is there a way to define or set the distance in pixels between consecutive ticks?
Thanks. If not precise pixels then, is there anyway to change the distance or relative distance between consecutive ticks?
Well the ticks even might not be equidistant because of rounding up/down to the closest pixel position ( doubles -> integers ! ).
In general the ticks are related to scale values - never to widget coordinates. So you have to set up an event filter for the plot canvas adjusting the ticks somehow to the geometry of the canvas.
Uwe
Thanks Uwe, that makes sense. I used QwtPlot::setAxisScale() with a defined step number and seems I may be able to work with that.
Don't know if it helps, but maybe QwtPlotRescaler offers something useful for you.
At least it does something similar: QwtPlot::setAxisScale according to resize events of the canvas.
Uwe
Bookmarks