QGraphicsView doesn't allow to scroll to added content
-
My application creates shapes and add them to the QGraphicsView that has
verticalScrollBarPolicy ScrollBarAlwaysOn
horizontalScrollBarPolicy ScrollBarAlwaysOn
sizeAdjustPolicy AdjustToContentsbut I cannot scroll past the size of the sceneRect. To see my shapes I need to zoom out (using scale() on the graphicsView widget).
Do I need to change the sceneRect at runtime after I added all my shapes ?
I tried to change the sceneRect to a QRectF having the size needed, or even a null QRectF, but nothing changes.

-
@Gilboonet said in QGraphicsView doesn't allow to scroll to added content:
but I cannot scroll past the size of the sceneRect
Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place
QGpahicsItems on it. Just confirm how you add these "shapes". AQGrphicsViewis a view onto this, so why do you want to scroll outside the scene rectangle?If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.
QGraphicsViewalso has its own scene rectangle, the area of the scene it covers. By default it returns theQGraphicsScene's scene rectangle. You can alter it for the view if you want that.@JonB Thank you, what you said helped me find what I was doing wrong : I did set the GraphicsView's sceneRect width and length properties. Setting them to 0 make it work as I needed. The screenshots are what I had as view, on the first one the scale as 100% and there are GraphicsItems to the left but no scrollbars. The second screenshot is at scale 30%.
-
My application creates shapes and add them to the QGraphicsView that has
verticalScrollBarPolicy ScrollBarAlwaysOn
horizontalScrollBarPolicy ScrollBarAlwaysOn
sizeAdjustPolicy AdjustToContentsbut I cannot scroll past the size of the sceneRect. To see my shapes I need to zoom out (using scale() on the graphicsView widget).
Do I need to change the sceneRect at runtime after I added all my shapes ?
I tried to change the sceneRect to a QRectF having the size needed, or even a null QRectF, but nothing changes.

@Gilboonet said in QGraphicsView doesn't allow to scroll to added content:
but I cannot scroll past the size of the sceneRect
Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place
QGpahicsItems on it. Just confirm how you add these "shapes". AQGrphicsViewis a view onto this, so why do you want to scroll outside the scene rectangle?If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.
QGraphicsViewalso has its own scene rectangle, the area of the scene it covers. By default it returns theQGraphicsScene's scene rectangle. You can alter it for the view if you want that. -
@Gilboonet said in QGraphicsView doesn't allow to scroll to added content:
but I cannot scroll past the size of the sceneRect
Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place
QGpahicsItems on it. Just confirm how you add these "shapes". AQGrphicsViewis a view onto this, so why do you want to scroll outside the scene rectangle?If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.
QGraphicsViewalso has its own scene rectangle, the area of the scene it covers. By default it returns theQGraphicsScene's scene rectangle. You can alter it for the view if you want that.@JonB Thank you, what you said helped me find what I was doing wrong : I did set the GraphicsView's sceneRect width and length properties. Setting them to 0 make it work as I needed. The screenshots are what I had as view, on the first one the scale as 100% and there are GraphicsItems to the left but no scrollbars. The second screenshot is at scale 30%.
-
G Gilboonet has marked this topic as solved on