In my main window's constructor I create a QGraphicsScene and View, set the scene to the view, add the QGraphicsView to the main window's layout, and then call QGraphicsView::centerOn(0,0), so that the QGraphicsView will show the scene in the middle of the view. However, it would display the scene offset by some weird amount, rather than in the middle like I want it to.

I've heard about some general funk relating to QGraphicsView and having to call it's methods *after* it's drawn onto the screen. Well, that didn't really help, because I was calling QGraphicsView::centerOn(0,0) at the very end of my main window's constructor... so I didn't see how to call it after that, unless I set up a timer or something stupid like that.

But then I had the idea to re-implement QMainWindow::showEvent, and call QGraphicsView::centerOn(0,0) in there, rather than in the constructor. What do you know... that fixed it!

My question is: Why does this happen? Am I missing something?