PDA

View Full Version : Control over QGraphicsScene placement in QGraphicsView



emmanuel
10th February 2010, 19:55
Hello,
Considering a QGraphicsScene that, under a given viewportTransformation, is much smaller than the QGraphicsView's viewport area, is it a fatality that the QGraphicsScene will be rendered either at the center or in a corner of the viewport, or is there a simple way, that I may have overlooked, to have absolute control over the position where the QGraphicsScene is rendered inside the QGraphicsView's viewport?
Thanks!

emmanuel
14th February 2010, 19:34
I somehow found the answer to this question: it lies in the code of the QGraphicsView widget.
So its seems the contents of a QGraphicsScene is always aligned to the viewport's center or corners when it lies completely inside the viewport area.

Lykurg
14th February 2010, 19:40
You can alter that behaviour by using QGraphicsView::setAlignment() or you can modify the rect of your scene to position your scene inside the view absolutely.

emmanuel
16th February 2010, 20:46
You can alter that behaviour by using QGraphicsView::setAlignment() or you can modify the rect of your scene to position your scene inside the view absolutely.

Yes indeed. Actually I found out that:
- Either the viewport area fits completely inside the sceneRect under the current transformation, in which case positioning of the scene is "absolute"
- Or not, in which case the viewport area is virtually reduced to fit inside the sceneRect, and aligned within the nominal viewport area according to the Alignement flags
Thanks