[Qt-interest] Paint QWebView to a QImage
Richard Hosking
richard at hovis.net
Tue Dec 29 01:05:43 CET 2009
Many thanks for the advice. The repaintRequested approach seems to
be the ideal method for me.
I have implemented this, but I am getting Painter errors:-
"A paint device can only be painted by one painter at a time"
...when painting to the QImage upon each repaintRequested call.
I suspect some concurrency issues here on my part!
I have attached my very stripped down test code which highlights
my issue. What do I need to do to make this work? Do I need to
'queue' the paint events myself so they do not overlap?
Richard.
(Qt 4.5.1 on Ubuntu 9.04)
Girish Ramakrishnan wrote:
> Hi,
> Use a plain QWebPage and connect to it' repaintRequested(QRect). You can
> then pass that QRect to QWebFrame's render() to update only the portion
> that got changed.
>
> (Also, your approach on changing the paintEngine won't work. Just
> reimplementing QWidget::paintEngine() doesn't actually switch the paint
> engine - It's complicated)
>
> Girish
>
> Richard Hosking wrote:
>> 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.
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QImageWebRendererTest.cpp
Type: text/x-c++src
Size: 1078 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091229/0090b4df/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QImageWebRendererTest.h
Type: text/x-chdr
Size: 529 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091229/0090b4df/attachment-0001.bin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: QImageWebRendererTest.pro
Url: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091229/0090b4df/attachment.pl
More information about the Qt-interest-old
mailing list