<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><pre style="font-size:12px;line-height:14.390625px;margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top"><span>m_d<span>-</span><span>></span>zoomManager<span>-</span><span>></span>zoomController<span>()->resetToFixedZoom();</span></span></pre>

<pre style="font-size:12px;line-height:14.390625px;margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top"><pre style="margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top">
<span>m_d<span>-</span><span>></span>canvasController<span>->setPreferredCenter(widgetSizeRect.center());</span></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top">
<span>m_d-<span>></span>canvasController->recenterPreferred()</span></pre></pre></div></blockquote></div></div></div></blockquote></div><br>This approach works somewhat ok, but it is needed to investigate how to calculate<span><span> widgetSizeRect.center()</span></span> value. If we do it in a straightforward way, like QPointF(widgetSize.height()/2, widgetSize.height()/2), then it works like that:<br>
<br>1) When the image is heavily zoomed in, that is "documentOrigin" == 0, the cropped area is put somewhere near to the center (not exactly, though).<br>2) When the image is zoomed out, origin != 0, then the image jumps to the topleft corner o fthe widget.<br>
<br>I think we just need to recall how the value of the preferred center is calculated (i would use that unittest) and calculate that properly here.<br><br>-- <br>Dmitry Kazakov