how to force QGraphicsScene to scroll all the way to the right
-
When I have items in a QGraphicsScene, if they exist outside the viewport, I get scrollbars automatically.
How can I force programmatically, scroll all the way to the right or left?
-
This might help: Using your
QGraphicsView::horizontalScrollBar()
you can try:view->horizontalScrollBar()->setValue( view->horizontalScrollBar()->maximum() );
This would bring you to the right. If you want to the left, use
minimum()
instead. -
I would say it is function of graphicsView, not scene.
Check void QGraphicsView::centerOn ( const QPointF & pos ).
Also scrollbar functionality is limited to max int. I would not rely on it. -
Thank you both, both approaches seem to generally work.