Using QGraphicsWebView to render HTML and access the raw bits

2k views Asked by At

I believe it's possible to render HTML to a QGraphicsWebView and get access to the raw bits that comprise the page.

My question is: do I also need a QGraphicsScene, QGraphicsView etc. etc. if all I need is a single HTML widget? I have something working right now but it's grown in complexity and I'm wondering if I can simplify it.

I also need to send mouse and keyboard events into the QGraphicsWebView.

Put another way, what is the absolute minimum I need to render an HTML page to memory using QGraphicsWebView?

Thank you in advance.

Samantha.

2

There are 2 answers

2
Stephen Chu On

If I read it correctly that you want a HTML page rendered into some sort of image data, then maybe QWebView is easier. Since it's a QWidget, it supports rendering onto a paint device which can be a QPixmap or QImage.

0
Ariya Hidayat On

If you just need to render an HTML page to an offscreen buffer, QWebPage is more than enough. See the websnap example or PhantomJS (I wrote both).

As for plugins like Flash, QGraphicsWebView has some tricks to fool Flash to render it offscreen. But this may or may not work, depending on the situation. You have no choice but to try and evaluate it on a case by case basis.