Please nominate your Qt Champions for 2021!

Centered zoom in a qgraphicswebview

  • Hi everyone,

    I'm trying to do a centered zoom in a qgraphicswebview using setScale, unfortunately it zooms at coordinates 0,0 and I'd like to have it zoomed to the center.
    How can I do this?

    Thank you.


  • Did you try something like this :

  • I tried something like this some time ago but I had problems when panning the view...I wasn't able to pan it everywhere like it was blocked to a smaller "bounding" rect...

  • I think the panning is limited to the scene or view sceneRect.
    Maybe you called setSceneRect with that "smaller bounding rect" ?

  • I simply do :

    @void MyWebView::centeredZoom(qreal delta)
    webview->setScale(webview->scale() + delta);

    It zooms centered but if I try to pan after a zoom I'm not able to reach the upper-left part of the webpage. Moreover the lower-right part is something out of the page.

Log in to reply