[Qt-interest] Paint QWebView to a QImage
Gilles Valette
gilles.valette at univ-reims.fr
Tue Dec 29 05:58:28 CET 2009
Message de Richard Hosking <richard at hovis.net>:
> 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.
Hi,
A QImage has its own QPaintEngine. This code does not cause any error
and writes "repaint" and "end repaint" several times to the console:
void QImageWebRendererTest::repaintRequested(const QRect &dirtyRect)
{
qDebug("repaint");
QPainter* imagePainter = p_qimage->paintEngine()->painter();
//imagePainter->begin(p_qimage);
p_qwebpage->mainFrame()->render(imagePainter, dirtyRect);
//imagePainter->end();
qDebug("end repaint");
}
Hope this helps,
Gilles
More information about the Qt-interest-old
mailing list