Hi, I’ m trying to use WebChannel in my V-play app to call QML methods and sginals from remote server, but I don’t know how to do that on Android. WebEngineView is not supported. This is simplified example:
import Felgo 3.0
import QtQuick 2.0
import QtWebView 1.0
import QtWebChannel 1.0
App {
NavigationStack {
Page {
title: qsTr("Main Page")
Rectangle {
id: rect
width: 50
height: 50
color: "red"
function someMethod() {
console.log("in QML");
}
}
WebView {
id: webView
anchors.top: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
url: "http://buddyintour.com/someFile.html"
WebChannel {
registeredObjects: [rect];
}
}
}
}
}
someFile.html placed on my server. There is qwebchannel.js in the same folder.
<!DOCTYPE html>
<html>
<head>
<script src="qwebchannel.js"></script>
</head>
<body>
<script>
if(typeof qt == "undefined") console.log("qt is not ok");
else {
var channel_obj = new QWebChannel(qt.webChannelTransport, function(channel){
var rect = channel.objects.rect;
rect.someMethod()
});
}
</script>
</body>
</html>
I suspect that connection I want to realize is not as easy as I think :/. Do you have any ideas how to make my QML objects visible from html?