Solved Using WebChannel and WebEngine IPC to get access to QtObjects from HTML
-
Hi all,
I'm trying to establish a connection between the HTML and QtQuick Application. On the QML Side I create an QtObject and add it to the WebChannel
QtObject{ id: rotateID WebChannel.id: "rotateJS" function screenOrientation(value){ //do something } } WebEngineView { id: webEngine WebChannel{ id: testobject registeredObjects: [rotateID] } }
Inside the HTML I'm using the
qwebchannel.js
and try to call this functionnew QWebChannel(qt.webChannelTransport, function (channel) { channel.rotateJS.screenOrientation("portrait"); });
Unfortunately it seems that the communction via the WebEngine IPC doesn't work. Does anyone have experience with this?
Best,
Dominator -
you can check if there are any javascript errors on the console.
-
I don't get any errors. I have no idea what else i can try
-
I found the problem.
You have to set the
webChannel
property of theWebEngineView
WebEngineView { id: webEngine webChannel: testobject } WebChannel{ id: testobject registeredObjects: [rotateID] }