Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.1
-
None
-
probably all. I use archlinux with pyside 5.14.1, python 3.8
Description
When calling QGraphicsView::centerOn(QPointF) it will modify the horizontal and vertical scroll bars. It does not however sync the viewport transform. As such it becomes 'out of sync'.
Below a pyside2 script that illustrates the problem:
pixmapitem = QGraphicsPixmapItem() pixmapitem.setPixmap(...) view.scene().addItem(pixmapitem) print(view.transform()) view.fitInView(pixmapitem, Qt.KeepAspectRatioByExpanding) print(view.transform()) # unchanged wrt previous print
Expected behavior: both scrollbars and the transform is updated.
A possible solution could be the following 'code' for centerOn that will modify the transform.
QGraphicsView::centerOn(QPointF center) { current_center = mapToScene(viewport().rect().center()); translate(current_center.x() - center.x(), current_center.y() - center.y()); }
This will also update the scrollbars via centerView call in setTransform.