Resize all images in a QWebElement to a fixed size



  • I am trying to load content of a HTML page with QWebView and I search for the content with using QWebElement.
    It is working perfectly, but when QWebView tries to display large images, it looks really weird, because the text automatically fits into the QWebView window, but whenn the image is too big for the window it adds a scrollbar just for the image.
    My question is: Is there a way to resize the width of all images in a QWebView to fit the size of the window?

    My code looks like this:

    QUrl url("some url");
    ui->webView->load(url);
    QEventLoop loop;
    connect(ui->webView, SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
    loop.exec();
    
    QWebElement webFrame= ui->webView->page()->mainFrame()->findFirstElement("some element images");
    QString string = webFrame.toInnerXml();
    ui->webView->setHtml(string);
    ui->webView->setEnabled(true);

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.