2

I created simple project for displaying local .html page. I used Qt5.4 with QWebView there. But after switching to Qt5.6 I noticed that Qt WebKit is deprecated and not supported any more. Thus I decided to replace Qt WebKit functionality with one from the Qt WebEngine.

After replacing QWebView with QWebEngineView I investigated that setZoomFactor method has no effect. Is it known issue? How can I handle with this?

EDIT: An interesting thing have been investigated recently. I use setHtml method for setting content of local .html files to my QWebEngineView. These files also contain references to images. So I set baseUrl parameter as a relative path to required images. In that case using of setZoomFactor method has no effect.

But when I don't set relative path to images as parameter, images are absent on QWebEngineView but zoom functionality works. Any ideas what is wrong here?

Vasyl
  • 404
  • 1
  • 6
  • 19
  • can you zoom using the evaluate function and zooming in java script ? – Midhun Apr 09 '16 at 18:23
  • No. I've just trying to use built-in `setZoomFactor` method. May be some additional settings should be set to enable zoom possibility? – Vasyl Apr 10 '16 at 21:02

3 Answers3

2

Setting zoomFactor for QML WebEngineView in Qt 5.11 using QML zoomFactor property or C++ setZoomFactor (private-API) did not work as expected. I discovered from comments in QT Bug 51992 that it works when set after a page load.

QML solution:

    WebEngineView {
        // ...
        onLoadingChanged: {
            zoomFactor = 0.75
        }
    }

QWebEngineView solution: connect to the loadFinished signal, and set zoomFactor after each page load:

main.cpp (after engine.load call):

QWebEngineView *webView;  // = ...
QObject::connect(webView, &QWebEngineView::loadFinished,
                 [=](bool arg) {
    webView->setZoomFactor(zoomFactor);
});
mstrthealias
  • 2,781
  • 2
  • 22
  • 18
1

It seems to be a known bug in this version of Qt. You can check by yourself here : Qt Bug 51992.

Basically, it is said that :

This looks like a known glitch that is currently happening because of the Chromium API that we use for setting the zoom factor.

And also :

Chromium limits the zoom factor to a maximum of 5.0 - any calls with a number higher than that will have no effect.

Hope that will help you.

IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
  • 1
    I am aware of [Qt Bug 51992](https://bugreports.qt.io/browse/QTBUG-51992) But I use adequate values of zoom factor such as 1.25, 1.625 etc. `setZoomFactor` method doesn't work at all. – Vasyl Apr 11 '16 at 07:29
  • Oh, I thought you were asking "Is it known issue?" so I just answered your question... – IAmInPLS Apr 11 '16 at 07:30
  • By the way, did you read other bug reports on this topic? For some application, it is know that this method doesn't work at all, and its resolution is in progress (so for the next version of Qt); See for example bugs 51851 and 51969. – IAmInPLS Apr 11 '16 at 07:55
0

The setZoomFactor does not function properly in the QT 5.15 release.

Call setZoomFactor multiple times to resolve the problem.

WebEngineView {
    function setZoomFactor(real) {
        zoomFactor = real
        zoomFactor = real
        zoomFactor = real
    }
}
김지민
  • 13
  • 3