Qt Code:
  1. void GraphicsView::zoom(qreal s){
  2. scale(s, s);
  3. zoomLevel *= s;
  4. }
  5.  
  6. void GraphicsView::zoomToWidth(){
  7. zoom((qreal)width() / (scene->sceneRect().width() * zoomLevel)); //this causes both scroll bars to appear
  8.  
  9. if(horizontalScrollBar()->isVisible() && verticalScrollBar()->isVisible()){
  10. //...
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

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?