
Originally Posted by
yogeshgokul
It means you have simply called graphicsView->scale(slider->value(), slider->value()). But this is not a correct way to scale using slider. By this if your slider value is 60, your gv will be scaled 60 times, that you probably never wants.
You should calculate the scale factor and then scale the graphicsView. Means your scale factor should be a real value, simply try this.
qreal sf = 0.0;
sf = slider->value()/10.0;
graphicsView->matrix().reset();
graphicsView->scale(sf, sf);
qreal sf = 0.0;
sf = slider->value()/10.0;
graphicsView->matrix().reset();
graphicsView->scale(sf, sf);
To copy to clipboard, switch view to plain text mode
I just uploaded an attachment with a app that reproduces the problem. Here is the SLOT thats takes care of the scaling:
int tempScale = 0;
void Widget::resizeClock(int t)
{
if(t < tempScale){
clock.scale(.9,.9);
}else if(t > tempScale){
clock.scale(1.1,1.1);
}else{
qDebug() << "equal";
}
tempScale = t;
}
int tempScale = 0;
void Widget::resizeClock(int t)
{
if(t < tempScale){
clock.scale(.9,.9);
}else if(t > tempScale){
clock.scale(1.1,1.1);
}else{
qDebug() << "equal";
}
tempScale = t;
}
To copy to clipboard, switch view to plain text mode
Bookmarks