Can also use QGraphicsView::fitInView() with Qt::KeepAspectRatio in the resize event if you don't want distortion due to changes in the width / height ratio on resizing. That also will center the scene in the view.

Note that calling setSceneRect() will change *all* views of the scene, not just the one with focus. So if you have the same scene displayed in more than one window, you want the method I described (which changes only the scaling used by the view, not the scene dimensions), otherwise the scene will look fine in one view, but not in any of the others.