I need to integrate the zoom slider for QGraphicsViewin Qt 4.x, I have a working implementation that looks something like this:
connect(slider, SIGNAL(valueChanged(int)), customGraphicsView, SLOT(setZoomLevel(int));
In the slot for setZoomLevelI have the following
void CustomView::setZoomLevel(int level)
{
if(zoomLevel - level < -1){
setZoomLevel(level - 1);
}else if(level - zoomLevel < -1){
setZoomLevel(level + 1);
}
if(level < zoomLevel){
scale(1 - (scaleFactor * (zoomLevel - level)), 1 - (scaleFactor * (zoomLevel - level)));
}else if (level > zoomLevel){
scale(1 + (scaleFactor * (level - zoomLevel)), 1 + (scaleFactor * (level - zoomLevel)));
}
zoomLevel = level;
}
So my problem is conjugating a slider that has a value from n to m to represent the zoom level for a function scale() QGraphicsViewthat takes two floating point values to propagate the scene to get a new size.
So the problem I am facing is that if you accept 1 * .9 * 1.1, you still will not get 1, but instead .99, this is a bit because this is not the right formula. Thus, my maximum increase becomes less and less over time.
, , "", , .
?