QT QWebEnginePage::setWebChannel() transport object

Short answer: add <script type=”text/javascript” src=”https://stackoverflow.com/questions/31928444/qrc:///qtwebchannel/qwebchannel.js”></script> to your html page (before you call new QWebChannel of course), and remove the line view->page()->runJavaScript(qwebjs); //this is qwebchannel.js from your C++ code. Long answer: I too had a ton of trouble figuring out how to use QWebChannel without WebSockets correctly — managed to get it working after digging … Read more

Qt Webengine not loading openstreetmap tiles

By default QtWebEngine does not set default headers like popular browsers do. In this case the openstreetmap server needs to know the “Accept-Language” to produce the maps since for example the names of the cities will depend on the language to filter non-browser traffic. The solution is to implement a QWebEngineUrlRequestInterceptor that adds that header: … Read more

How to use Qt WebEngine and QWebChannel?

In Qt5.6, if you want to make C++ part and JavaScript to communicate, the only way to do it is using QWebChannel on a QWebEngineView, as you stated. You do it this way in the .cpp file: m_pView = new QWebEngineView(this); QWebChannel * channel = new QWebChannel(page); m_pView->page()->setWebChannel(channel); channel->registerObject(QString(“TheNameOfTheObjectUsed”), this); Here, you just say that … Read more