How to get photos from QWebView

Does anyone know how to get image from qwebview? My situation is that there is no way to use the image URL and then QNetworkRequest. I just need to β€œextract” the image from QWebview.

+6
source share
1 answer

First you need to get a QWebElement with the image you want to save - if you don't have one, 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"); 
+10
source

Source: https://habr.com/ru/post/914241/


All Articles