Does anybody know how to get a picture from qwebview? My situation is, there is no scope to use the image url and then a QNetworkRequest. I just need to 'extract' the image from the QWebview.
First you need to get the QWebElement
with the image you want to save - if you don't have it already, a good way to get it is
QWebElement el = view.page()->mainFrame()->findFirstElement("IMG[src='path/to/img'");
assuming view
is the name of your QWebView
. Then,
QImage image(el.geometry().width(), el.geometry().height(), QImage::Format_ARGB32);
QPainter painter(&image);
el.render(&painter);
painter.end();
image.save("path/to/img.png");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With