Reimplement resizeEvent for the view and call QGraphicsView::fitInView() passing the rect you want matched in the view.
Reimplement resizeEvent for the view and call QGraphicsView::fitInView() passing the rect you want matched in the view.
This works just fine, but then you run into the problem that if you use the default, the aspect ratio changes, the font scaling gets strange, and the plot just gets ugly. I had to jump through a lot of hoops to get an x-y plot look "normal" no matter what size window it was in. Using Qt::KeepAspectRatio makes it a bit better, but then you must reposition the scene by using QGraphicsView::centerOn().Reimplement resizeEvent for the view and call QGraphicsView::fitInView() passing the rect you want matched in the view.
Nobody said anyone was to use any defaults. There are three values to pass for the argument to fitInView and trying all of them is not that hard. The method does exactly what it name says -- it makes sure a specific rectangle matches the view. it says nothing about what the view gets centred on.
Bookmarks