[webkit-qt] Pinch zoom for QWebView?

Harri Pasanen grego at mpaja.com
Mon Jan 10 08:51:50 PST 2011


Saturday, January 08, 2011 05:35 pm 
Kenneth Rohde Christiansen writes:
> Let me repost as I was subscribed with another address:
> 
> Hi there,
> 
> To get the right result you will need to scale the contents and not
> zoom it, as zooming is not the same as just applying a scale. Scaling
> the QPainter would do. On the other hand, you cannot ensure a really
> smooth pinch animation as you repaint the whole time without being
> able to ensure how long that repaint will take. What you really should
> do is to use the QGraphicsWebView as it supports a tiled backing
> store. Then you can pinch the following way:
> 
> 1) freeze the backing store
> 2) apply a scale to the QGraphicsWebView (this will scale the frozen
> tiles (pixmaps))
> 3) unfreeze the backing store (it will now repaint and become crisp)
> 
> It would be nice if you could add such support to our demo/test
> browser QtTestBrowser found in our webkit repository.
> 
> Just to make it clear, with the QGraphicsWebView you do not need to
> change the QPainter directly. A QGraphicsWebView is a QGraphicsWidget
> and it has a ::setScale() method, which you can use.
> 
> I forgot to mention one more thing:
> 
> 1) You need to enable resizesToContents if you are going to scale the
> QGraphicsWebView, which means that you need to implement your own
> panning as well. ie have a QGraphicsItem serve as a view to your
> QGraphicsWebView. Every time, the viewport is (re)sized, or a
> pinch/panning animation has ended, you will need to call
> setActualVisibleContentsRect(). Do not do this during animations for
> performance reasons.
> 
> QtTestBrowser shows how to use resizesToContents with tiling etc, but
> it still lacks the setActualVisibleContentsRect() code, which is
> needed:
> 
> 1) for not ending up in infinit tiling creation (it needs an initial
> size; the (re)sizing)
> 2) for programmatic scrolling to work, anchor links (it needs the new
> visible rect after each pinch, panning ended)
> 

I'm not quite sure what you mean with "for programmatic scrolling to work, 
anchor links"...

What do you mean by "anchor links"

Anyway, thanks for the advice.   If I have the time I'll delve into this a bit 
deeper, no promises yet...  If I get it to work I'm happy to contribute it to 
QtTestBrowser.

Harri


More information about the webkit-qt mailing list