[webkit-qt] Javascript inside pixeldata of QImage

Youri Westerman youri at pluxcustoms.nl
Tue Mar 19 02:39:05 PDT 2013

Hi All,

Basically I do the same thing as the example here:

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.

QImage im(page->viewportSize(), QImage::Format_ARGB32);
QPainter painter(&im);


const char * path = "/tmp/webkitimage/test2.img";

FILE * file = fopen(path, "w");

if(!file) {
	std::cout << "Could not open file to save image data to: " << path <<

std::cout << "Opened file to write image data to!" << std::endl;

uchar * imageData = im.bits();
fwrite(imageData, 1, im.byteCount(), file);

Page is an object of type QWebPage.

Thanks in advance for any pointers on how to resolve this.

Youri Westerman

More information about the webkit-qt mailing list