Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Centered zoom in a qgraphicswebview
Forum Updated to NodeBB v4.3 + New Features

Centered zoom in a qgraphicswebview

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrAlmond
    wrote on last edited by
    #1

    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.

    mrA

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

      Did you try something like this :
      @yourWebView->setTransformOriginPoint(yourWebView->boundingRect().center());@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrAlmond
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexisdm
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrAlmond
            wrote on last edited by
            #5

            I simply do :

            @void MyWebView::centeredZoom(qreal delta)
            {
            webview->setTransformOriginPoint(webview->boundingRect().center());
            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved