Search code examples
qt4

how to Fit QGraphicsScene in a QGraphicsView


I want to to fit a QGraphicsScene in a QGraphicsView with different dimensions, such that it will shrink or expand according to size of view, and there should be no any scrollbar.


Solution

  • scaling the view like bellow doing what required:

    view->scale(frameWidth / sceneWidth, frameHeight / sceneHeight);