Pregunta

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 ?

¿Fue útil?

Solución

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).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top