1
votes

When I set the scene rect to the same rect of the viewport:

mCanvasScene->setSceneRect(mCanvasView->viewport()->rect());

The QGraphicsView creates scrollbars in the widget, but if the scene is the same size of the viewport why there are scrollbars ? It seems that the rect() from the viewport isn’t the correct size of the viewport area.

Does anyone knows how to set the scene with the same size of the visible area of the viewport ?

1
Can you provide an SSCCE? I can't seem to reproduce this. When I do view->scene()->setSceneRect(view->viewport()->rect()); I get no scrollbars.thuga
A GraphicsView on a GraphicsScene is like a window looking out into the world. It seems strange to want to set the scene to the size of the view.TheDarkKnight
Why is strange to want the scene with the same size of the viewport ?Tarantula
thuga, are you calling it before or after the form is show ? I'm calling if AFTER the form is show.Tarantula

1 Answers

1
votes

QGraphicsView inherits from QAbstractScrollArea, and viewport() returns widget managed by scroll area, which is usually bigger than the actual scroll area widget (reason for using scroll area in the first place).

Correct size of the visible area is the size of QGraphicsView (calling the inner widget viewport is little misleading).