HTML5-JS-C++ interaction
-
Hi,
I am trying to develop an app for android/ios/windows for which I want UI to be in html/css.
I tried using webkit, but I assume we can't use it anymore as it is deprecated and will be removed in future releases (moreover webkit was nit working on android mobile). So I used QTWebengine. Now my problem is when I try to communicate from my html to js it is fine, but from js to c++ is not working. Everywhere I am getting examples using webkit, but not with webengine. Can someone please help ?
Also is it possible to create an app using html/css (and background in c++ communicating via js) to run fine on desktop and mobiles ??Thanks
Pankaj Kushwaha -
@pankaj4288 said:
my problem is when I try to communicate from my html to js it is fine, but from js to c++ is not working. Everywhere I am getting examples using webkit, but not with webengine. Can someone please help ?
Hi Pankaj,
From what I understood, you can have a look at QWebChannel standalone example given with Qt 5.5. It gets more complicated than with QtWebKit, and I was wondering if I were missing something or if it were supposed to change eventually, but I got no reply.
Clem
-
Thanks a lot..
Yes the code is very complicated, and it seems that we are sending some data in json format from our C++ app to server and that is being displayed on browser. While I am looking for some example in which app's UI will be in html and all backend operations (like write/read database) will be in C++. These html will be rendered using QTWebengine, as QWebkit is deprecated. -
Hopefully they make some more examples and improvement so that using QWebChannel becomes easy to use like with QWebkit (Qtwebkit-bridge). Sending object from C++ to JS and JS to C++ was easy with a simple line of code once you did "addToJavaScriptWindowObject".
Now you have to include QWebChannel.js, and do a bunch of other steps. I wish all theses steps could be automated and done under the hood by Qt using some flag on the QWebEngineView for example.
That and also QWebEngine is harder to deploy compared to QWebKit, the QWebEngineView is not present in designer..etc. all that makes me stick for QWebKit for now... -
@pankaj4288
Can you send data from c++ object back to html/js? If so, do you have suggestion on what should be done different in my question here ... with that code I an unable to get variables in html/js.