From 88c1904c3f9e17f44a1ebf8fd7508321f4b674a2 Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Thu, 26 Dec 2024 18:59:08 -0500 Subject: [PATCH] Pan image when resizing window to maintain focal point --- src/qvgraphicsview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qvgraphicsview.cpp b/src/qvgraphicsview.cpp index d5bd9e5e..24e8a570 100644 --- a/src/qvgraphicsview.cpp +++ b/src/qvgraphicsview.cpp @@ -72,6 +72,9 @@ void QVGraphicsView::resizeEvent(QResizeEvent *event) return; QGraphicsView::resizeEvent(event); + + const QPoint sizeDelta = QRect(QPoint(), event->size()).bottomRight() - QRect(QPoint(), event->oldSize()).bottomRight(); + scrollHelper->move(QPointF(sizeDelta) / -2.0); fitOrConstrainImage(); }