From eef9b8725637f448f9f10ba9851f49c9df4bfe6f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 3 Jan 2017 17:16:26 +0100 Subject: Use the contentsSize from qtwebengine. We can't bind directly because accessing contentsSize before loading an html seems to cause a crash. --- components/package/contents/ui/WebView.qml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'components/package/contents/ui/WebView.qml') diff --git a/components/package/contents/ui/WebView.qml b/components/package/contents/ui/WebView.qml index fd418879..bb6a8df7 100644 --- a/components/package/contents/ui/WebView.qml +++ b/components/package/contents/ui/WebView.qml @@ -17,21 +17,13 @@ */ import QtQuick 2.7 -import QtWebKit 3.0 -// import QtWebEngine 1.3 //This would give use contentsSize -import QtWebEngine 1.2 +import QtWebEngine 1.3 Item { id: root property string content; - property int contentWidth: helperView.contentWidth; - property int contentHeight: helperView.contentHeight; - //FIXME workaround until QtWebEngine 1.3 with contentsSize - WebView { - id: helperView - visible: false - Component.onCompleted: loadHtml(content, "file:///") - } + property int contentWidth: 0; + property int contentHeight: 0; WebEngineView { id: htmlView anchors.fill: parent @@ -40,9 +32,12 @@ Item { console.warn("Status is ", loadRequest.status); } Component.onCompleted: loadHtml(content, "file:///") + onContentsSizeChanged: { + root.contentWidth = contentsSize.width + root.contentHeight = contentsSize.height + } } onContentChanged: { htmlView.loadHtml(content, "file:///"); - helperView.loadHtml(content, "file:///"); } } -- cgit v1.2.3