[webkit-qt] Javascript inside pixeldata of QImage

Youri Westerman youri at pluxcustoms.nl
Tue Mar 19 08:08:45 PDT 2013


Thanks for your quick reply.
Actually I have extended the QWebPage class and overridden the
javascriptConsoleMessage method. All the javascript code does is wait
for a couple of seconds and then prints a console message. The thing
is that it works with qt4.8 and does not in qt5.

However I would very much like to use qt4.8 at the moment because
there are no packages of qt5 available for ubuntu.

Furthermore when I call the bits() method on a QImage painted through
the render method of QWebPage and inspect the data which was returned
there is javascript in there, while there should only be ARGB pixel
data... Seems like a bug to me, but maybe I'm doing something wrong?

2013/3/19 Jocelyn Turcotte <jocelyn.turcotte at digia.com>:
> On Tue, Mar 19, 2013 at 10:39:05AM +0100, Youri Westerman wrote:
>> Hi All,
>>
>> Basically I do the same thing as the example here:
>> http://qt-project.org/doc/qt-4.8/qwebpage.html#details
>>
>> But instead of saving the image to disk I'm planning on doing other
>> things with the data. Anycase when I retrieve the pixeldata from the
>> QImage object by calling bits() on it and then inspect that data, I
>> found that there is javascript code in there. So it seems to me that
>> there is something going with the render method of the QWebPage class
>> or something.
>>
>> Anyone out there that can shine their light on this? I tried doing the
>> same thing with qt5, but unfortunately the javascript code inside the
>> webpage does not even get executed there.
>
> loadFinished means that all static resources have been fetched from the network and doesn't directly wait for script execution.
> Also for more complex pages like gmail, there is no easy way AFAIK to guess from the outside when the page passed from an "initializing" state to a "displaying contents and processing user input" state.
>
> I would suggest you to try using QWebFrame::initialLayoutCompleted (which should only be emitted after the body's onload event), or to start an additional timer following it if that still doesn't work.
>
> Cheers,
> Jocelyn


More information about the webkit-qt mailing list