0

Qt 5.6 RC does contains only webengine and webview, QWebView Depens On QwebEngine but QWebengine compiling only wtih MSVC 2013 and MSVC 2015 compiler.

and so how i can use javasrcipt function in Qt 5.6.

I have a GPS coordinates latitue and longtite from positioning module. i want to use it with view in QWebKit but QWebKit removed from Qt 5.6 RC.

Qt 5.5.1 can do above that i want but some specifiec libraries have bug.

I use a MinGW compiler and i want to show coordinate on google map. Disturbingly how i do that?

CMLDMR
  • 334
  • 2
  • 12

2 Answers2

0

Please find the question and the answer from here

You have to use QWebChannel in both source ccode and the Javascript side.

Register the class using below method

QWebChannel *channel = new QWebChannel(page());
channel->registerObject(QStringLiteral("jshelper"), &helper);
page()->setWebChannel(channel);

here helper is the object you want to share with javascript

and in javascript you can retrieve the object using the below code

document.addEventListener("DOMContentLoaded", function () {
            new QWebChannel(qt.webChannelTransport, function(channel) {
                // all published objects are available in channel.objects under
                // the identifier set in their attached WebChannel.id property

                jshelper = channel.objects.jshelper;

            });
});

If you want to run the javascript from Qt you can use runJavaScript function, please read from here

Community
  • 1
  • 1
Gilson PJ
  • 3,443
  • 3
  • 32
  • 53
  • this way you can share the c++ object with javascript. I will edit the answer in the way how we can use javascript function in Qt – Gilson PJ Mar 15 '16 at 07:35
  • your solution is using a webenginewidgets library and this library only support by msvc 2013 and 2015 compiler. still i am using android g++ on windows 7 and it doesn't work with it? am i understand wrong. I opened a Bug for this isue – CMLDMR Mar 29 '16 at 13:21
  • ok..am not sure about windows. It was executed fine in my ubuntu machine – Gilson PJ Mar 30 '16 at 05:21
0

I opened a bug for this issue at this BUG REPORT : LINK

Solution is you have to download webkit from source and compiling with Qt5.6 Library again, you can use it again and evulating javascript. still WebEngineWidgets supports only two compiler thats are MSVC 2013 and 2015. Not Android g++ or Others.

CMLDMR
  • 334
  • 2
  • 12