1
votes

I'm creating an application with as purpose easily creating a quiz to later display on a projector. I was planning on using a QGraphicsView and QGraphicsScene to display the screen.

I am wondering how (if it is possible at all) I can make the scene a fixed size, so that the view will always display the whole scene. I.e. if the window size is changed and the graphicsView is resized, the scene is displayed identical to other sized, but then scaled. I have tried messing around with the QGraphicsView::fitInView and the Rectangles, but nothing really worked out.

If there is another data structure which is more suited for my needs, I'm very open for suggestions!

1

1 Answers

0
votes

You can reimplement resizeEvent( QResizeEvent *event ) in your QGraphicsView like:

void MyView::resizeEvent(QResizeEvent *event)
{

    fitInView(0, 0, 500, 500,Qt::KeepAspectRatio);

    QGraphicsView::resizeEvent(event);
}