I am migrating my application from WebKit to WebEngine (it seems that it is better for rendering angular-basad html). I ran into a problem that I cannot enable QtWebEngine to load a local iframe, despite the fact that I set all the possible settings that I found:
Code from mainwindow.cpp
view->page()->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
view->page()->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
view->page()->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
view->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
view->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
view->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
The simplest example is to take a FancyBrowser based on WebEngine (\ Examples \ Qt-5.4 \ webenginewidgets \ fancybrowser) and try to load the local html file into it as follows:
Index.html:
<html>
<head>
<title>Hi there</title>
</head>
<body>
This is a page
a simple page
<iframe id="some_idrame" width="0" height="0" style="border: none" src="some_iframe.html" name="target" sandbox="allow-scripts"></iframe>
</body>
</html>
some_iframe.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>La-la-la</title>
</head>
<body>
Lalala
</body>
</html>
If you configured env var QTWEBENGINE_REMOTE_DEBUGGING on some port, you can open 127.0.0.1:port and see this error in the console:
"Not allowed to load local resource".
, ... - WebEngine - "--disable-web-security"...
!