Next, let's take a look at how we can call C++ functions from JavaScript instead. For the sake of demonstration, I'll put a text label above the web view and we will change its text using a JavaScript function:
Normally, JavaScript can only work within the HTML environment and hence, is only able to alter HTML elements and not something outside the web view. However, Qt allows us to do just that by using the web channel module. So let's open up our project (.pro) file and add the web channel module to the project:
QT += core gui webengine webenginewidgets webchannel
After that, open up mainwindow.h and ...