[webkit-qt] Embedding a QWebView into a QScrollArea

Simon Hausmann simon.hausmann at digia.com
Thu Feb 28 03:11:04 PST 2013


On Thursday, February 21, 2013 09:01:30 PM Jan Kundrát wrote:
> Hi folks,
> my application is an e-mail client which embeds one or more QWebView
> instances along with some common, shared headers into a single QScrollArea.
> The idea behind this is to make it possible to:
> 
> - use native widgets for headers etc,
> - be able to mix HTML from various message parts,
> - scroll all of this together.
> 
> After quite some struggling, we've achieved this and everything works great
> (including proper sizing which was rather PITA to configure properly, and
> including dynamic changes to the rendered tree in response to CSS
> pseudoclasses like :checked, yay).
> 
> Now, the missing bit is automatically moving the page to the place of the
> search result in response to QWebPage::findText. Because the QWeb...
> instances have no scrollbars and are embedded inside a QScrollArea, the
> QWebFrame::scrollPosition is always (0,0), and that's clearly a useless
> value here.
> 
> I've dug into the webkit sources to see what the suitable callback shall
> look like, and found a sweet comment
> (src/3rdparty/webkit/Source/WebCore/rendering/RenderLayer.cpp, line 1477):
> 
>   // This is the outermost view of a web page, so after scrolling this view
> we // scroll its container by calling Page::scrollRectIntoView.
>   // This only has an effect on the Mac platform in applications
>   // that put web views into scrolling containers, such as Mac OS X Mail.
>   // The canAutoscroll function in EventHandler also knows about this.
>   if (Frame* frame = frameView->frame()) {
>       if (Page* page = frame->page())
>           page->chrome()->scrollRectIntoView(rect);
>   }
> 
> ...and indeed, the ChromeClientQt defines that method as an empty stub.
> 
> I realize that this might not be a terribly important feature for most
> people (who would possibly put a QWebView into a custom QScrollArea, after
> all), but Apple needs that, I need that, and with the current QWebView, it
> isn't possible. Are there any chances of implementing a signal in the
> QWebView which is emitted when the contents is "scrolled" through this?

This seems like a resonable request to me and I can't see any of the existing 
signals that would fit for this. It also makes sense when using 
QGraphicsWebView or QWebView in ResizeToContents mode, I think.

How about

void QWebPage::rectangleVisibilityRequested(const QRect& rect);

?


What do the others think? Allan, Andras, Jocelyn?



Simon

P.S.: I tried Trojitá - nice app! I like the idea of small self-contained apps 
that in this case is a big lighter than Akonadi. Any plans on adding support 
for moving mails between folders? :)


More information about the webkit-qt mailing list