PDA

View Full Version : (Qt 4.8) QScrollBar::isVisible not updating after calling QGraphicsView::scale



ben1996123
14th June 2015, 18:50
void GraphicsView::zoom(qreal s){
scale(s, s);
zoomLevel *= s;
}

void GraphicsView::zoomToWidth(){
zoom((qreal)width() / (scene->sceneRect().width() * zoomLevel)); //this causes both scroll bars to appear

if(horizontalScrollBar()->isVisible() && verticalScrollBar()->isVisible()){
//...
}
}

But the if statement doesn't run, even though both scroll bars are visible. If I then immediately run zoomToWidth again, the if statement does run, so it seems like the scroll bars aren't being "updated" immediately. Is there a way to fix this?