how to get the real width and hight of the web pages what have loaded?
Unsolved
QtWebEngine
-
//m_WidgetBrowser means the widget of the webengineview connect(m_WidgetBrowser->page(), &QWebEnginePage::loadFinished, [this](bool ok) { if (ok) { m_WidgetBrowser->page()->runJavaScript("document.body.scrollWidth", [this](const QVariant &widthResult) { int pageWidth = widthResult.toInt(); int viewWidth = m_WidgetBrowser->width(); double zoomFactorWidth = static_cast<double>(viewWidth) / static_cast<double>(pageWidth); m_WidgetBrowser->page()->runJavaScript("document.body.scrollHeight;", [this,pageWidth](const QVariant &heightResult) { int pageHeight = heightResult.toInt(); int viewHeight = this->m_WidgetBrowser->height(); emit onSignalResize(pageWidth,pageHeight); //the signal is to reszie the widget of the webegine m_WidgetBrowser->resize(pageWidth,pageHeight); }); }); } }); }
I tested the code above.but on some platforms it worked.some dosent.
Is there any way to get the real width and height of the pages which loadfinished? -
and if I set the source file whit the setHtml() function.
it is hard to get the real height and width if the source was made by the txt.