Dear All,

First thing that should be written about hybrid C++/WebKit applications should be: "Never do it!!!". And here is why:

Imagine your hybrid application produces charts (Flot) and tables (SlickGrid), all JQuery based. Now, you would like to export these to an image (png, for instance). Flot charts are not simple to export, because they are composed of a set of canvases and div elements, so ideally you would like to simply render the containing div element. It sounds easy: get QWebElement and render it on to a QImage. However, the parent QWebFrame will always clip the content to the viewport, even if you specify your own clipping rectangle, so if your user wants to export only a partially visible element, the exported image gets screwed. Rendering QWebFrame is not an option, because this is also clipped to a viewport, because some retard made such a design.

Immediate solution is to clone the source webpage to another webpage, windowless, set it's viewport to whatever your like and export all you want from there. And here come new problems: cloned canvas QWebElement's do not carry image data! You have to export that data with "toDataUrl()" and import to the clone with "drawImage". You think it's working fine? Wrong. I exported data with "QVariant variantData = elem.evaluateJavaScript("this.toDataURL()");". Next I loop over cloned elements and pasted canvas data with "elem.evaluateJavaScript(QString("c = this.getContext('2d'); var image = new Image(); image.src = \"%1\"; alert(image.complete); c.drawImage(image, 0, 0);").arg(canvasDatas.takeFirst()));", where "canvasDatas" is a QStringList of canvas data. You are wondering what is this "alert" call doing there. Well, try to get this whole canvas cloning working without it...

Moreover, cloned elements do not carry computed css, which is the one governing rendering, hence cloning "SlickGrid" elements is screwed as well, so you go over all cloned elements and copy the computed style (WTF?).

The message is: QtWebKit is horribly broken and working with it simply wastes your time, instead of being productive.

By the way, the person who removed the old "clipRenderToViewport" API without replacing it with something usable should simply rot in hell.

Daniel Lewandowski