blob: 5929bea082ef3e76c3f4e854bf009f35ae7d4942 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtWebKit 3.0
Item {
id: root
property string html;
WebView {
id: webview
anchors.fill: parent
onNavigationRequested: {
// detect URL scheme prefix, most likely an external link
var schemaRE = /^\w+:/;
if (schemaRE.test(request.url)) {
request.action = WebView.AcceptRequest;
} else {
request.action = WebView.IgnoreRequest;
// delegate request.url here
}
}
onLoadingChanged: {
console.warn("Error is ", loadRequest.errorString);
console.warn("Status is ", loadRequest.status);
}
}
onHtmlChanged: {
// console.warn("HTML is ", html);
// The file:/// argument is necessary so local icons are found
webview.loadHtml(html, "file:///");
}
}
|