From cca7f55760f59dc4ada70ac866ab129b64e649db Mon Sep 17 00:00:00 2001 From: Jeena Date: Wed, 29 Jun 2016 22:02:34 +0200 Subject: [PATCH] Use the ID within WebEngineView to make it work with Qt 5.7 I have no idea why, I think it might be some timing issues while initializing the webengine, but when using runJavaScript() in the WebEngineView without referencing it with the id of that QML object it just throws the error that it doesn't know what runJavaScript() is. When we use the ID then it just works for some reason. --- qml/Content.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qml/Content.qml b/qml/Content.qml index 79b636e..017aa53 100644 --- a/qml/Content.qml +++ b/qml/Content.qml @@ -48,9 +48,9 @@ Item { function setPost() { if(post) { - runJavaScript("setArticle(" + post.jsonString + ")") + webView.runJavaScript("setArticle(" + post.jsonString + ")") } else { - runJavaScript("setArticle('logout')") + webView.runJavaScript("setArticle('logout')") } } @@ -58,8 +58,8 @@ Item { // font name needs to be enclosed in single quotes // and this is needed for El Capitain because ".SF NS Text" won't work var defFont = ', system, -apple-system, ".SFNSDisplay-Regular", "Helvetica Neue", "Lucida Grande"'; - runJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'" + defFont + "\";"); - runJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';"); + webView.runJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'" + defFont + "\";"); + webView.runJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';"); }