[Qt-interest] Paint QWebView to a QImage

Richard Hosking richard at hovis.net
Wed Dec 16 21:25:22 CET 2009


Hello, I am trying to render the contents of a QWebView
to a QImage instance.

I have tried the QWebFrame->render(QImage) method, but this
is not the correct approach for me as I need to render
at several frames a second.  I really only want to render
when changes occur on the widget to keep CPU usage down.

What I would ideally like is for QWebView to render directly
to a QImage.

I have tried subclassing QWebView's paintEngine() and
returning my QImage->paintEngine() but the image remains
unchanged.

I have also tried hooking into QWebView's event() and
listening for QEvent::Paint then calling
QPainter::setRedirected(QWebView, QImage) but again nothing
is produced in the image.

Any pointers?

(Qt 4.5.1 on Linux)

Kind regards,
Richard.



More information about the Qt-interest-old mailing list