Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.1
-
None
Description
Scenario 1:
1. Run the snippet below (the image will be downloaded and saved in cache)
2. Run the snippet again
Actual result:
See attached image scenario_1.png (only red background is rendered).
Expected result:
The image is fully rendered.
Scenario 2:
1. Uncomment the line that disables cache
2. Run the snippet
Actual result:
See attached image scenario_2.png (bottom part of the image is not rendered).
Expected result:
The image is fully rendered.
Adding delay using timer helps but it not suitable fix for production use.
#include <QApplication> #include <QWebEngineProfile> #include <QWebEngineView> auto html = "<!DOCTYPE html>" "<html lang=\"en\">" "<head>" " <meta charset=\"UTF-8\">" " <style>" " img { max-width:100%; max-height:100%; }" " div { height: 270px; width: 540px; }" " body { margin: 0; background-color: red; }" " </style>" "</head>" "<body>" "<div>" " <img src=\"https://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x5400x2700.png\">" "</div>" "</body>" "</html>" ; int main(int argc, char *argv[]) { QApplication app(argc, argv); // QWebEngineProfile::defaultProfile()->setHttpCacheType(QWebEngineProfile::NoCache); QWebEngineView view; view.show(); view.resize(540, 270); QObject::connect(&view, &QWebEngineView::loadFinished, [&view](bool isOk) { if (!isOk) return; view.grab().save("qt_page.png", "PNG"); }); view.setHtml(html); return app.exec(); }