title: QT QWebEnginePage::setWebChannel() transport object
body: <p>I'm using the QT WebEngine framework to display web pages. I'm injecting javascript into a page when it loads, and want to allow the javascript to be able to access a QT object. Apparently, to do this a QWebChannel must exist that establishes some IPC between chromium (the javascript) and the rest of my C++/QT project. I came across the QWebEnginePage::setWebChannel (QWebChannel *channel) function, however I can't find any examples of its use. The documentation (<a href="http://doc.qt.io/qt-5/qwebenginepage.html#setWebChannel">http://doc.qt.io/qt-5/qwebenginepage.html#setWebChannel</a>) mentions that qt.webChannelTransport should be available in the javascript context, but I don't see where that is established in qwebchannel.js (<a href="https://github.com/qtproject/qtwebchannel/blob/dev/src/webchannel/qwebchannel.js">https://github.com/qtproject/qtwebchannel/blob/dev/src/webchannel/qwebchannel.js</a>). I've seen the WebChannel examples (<a href="http://doc.qt.io/qt-5/qtwebchannel-examples.html">http://doc.qt.io/qt-5/qtwebchannel-examples.html</a>) and would like to avoid WebSockets if possible.</p>
  
  <p>Below is how I tried to implement the web channel.</p>
  
  <p><strong>Whenever a page loads I establish a channel and inject the javascript in C++:</strong></p>
  
  <pre><code>QWebChannel *channel = new QWebChannel();
  channel-&gt;registerObject(QStringLiteral("jshelper"), helper);
  
  view-&gt;page()-&gt;runJavaScript(qwebjs); //this is qwebchannel.js
  view-&gt;page()-&gt;setWebChannel(channel);
  view-&gt;page()-&gt;runJavaScript(myfunction); //function that calls QT object (jshelper)
  </code></pre>
  
  <p><strong>In Javascript:</strong></p>
  
  <pre><code>new QWebChannel(qt.webChannelTransport, function(channel) { ... });
  </code></pre>
  
  <p>Which results in the channel not being connected properly (assuming this is because of qt.webChannelTransport, as it was working when I was using WebSockets).  Any pointers to examples of QWebChannel being set up with QWebEnginePage this way is also appreciated.</p>