<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qwebchannel.cpp --> <title>QWebChannel Class | Qt WebChannel 5.11</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtwebchannel-index.html">Qt WebChannel</a></td><td ><a href="qtwebchannel-module.html">C++ Classes</a></td><td >QWebChannel</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#public-slots">Public Slots</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QWebChannel Class</h1> <!-- $$$QWebChannel-brief --> <p>Exposes QObjects to remote HTML clients. <a href="#details">More...</a></p> <!-- @@@QWebChannel --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QWebChannel></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += webchannel</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.4</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</a></td></tr></table></div><ul> <li><a href="qwebchannel-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><a href="qwebchannel.html#blockUpdates-prop">blockUpdates</a></b> : bool</li> </ul> <ul> <li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#QWebChannel">QWebChannel</a></b>(QObject *<i>parent</i> = Q_NULLPTR)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#dtor.QWebChannel">~QWebChannel</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#blockUpdates-prop">blockUpdates</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#deregisterObject">deregisterObject</a></b>(QObject *<i>object</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#registerObject">registerObject</a></b>(const QString &<i>id</i>, QObject *<i>object</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#registerObjects">registerObjects</a></b>(const QHash<QString, QObject *> &<i>objects</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QHash<QString, QObject *> </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#registeredObjects">registeredObjects</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#blockUpdates-prop">setBlockUpdates</a></b>(bool <i>block</i>)</td></tr> </table></div> <ul> <li class="fn">34 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li> </ul> <a name="public-slots"></a> <h2 id="public-slots">Public Slots</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#connectTo">connectTo</a></b>(QWebChannelAbstractTransport *<i>transport</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#disconnectFrom">disconnectFrom</a></b>(QWebChannelAbstractTransport *<i>transport</i>)</td></tr> </table></div> <ul> <li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li> </ul> <a name="signals"></a> <h2 id="signals">Signals</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwebchannel.html#blockUpdates-prop">blockUpdatesChanged</a></b>(bool <i>block</i>)</td></tr> </table></div> <ul> <li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li> <li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li> <li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li> <li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QWebChannel-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>Exposes QObjects to remote HTML clients.</p> <p>The <a href="qwebchannel.html">QWebChannel</a> fills the gap between C++ applications and HTML/JavaScript applications. By publishing a <a href="../qtcore/qobject.html">QObject</a> derived object to a <a href="qwebchannel.html">QWebChannel</a> and using the <a href="qtwebchannel-javascript.html">qwebchannel.js</a> on the HTML side, one can transparently access properties and public slots and methods of the <a href="../qtcore/qobject.html">QObject</a>. No manual message passing and serialization of data is required, property updates and signal emission on the C++ side get automatically transmitted to the potentially remotely running HTML clients. On the client side, a JavaScript object will be created for any published C++ <a href="../qtcore/qobject.html">QObject</a>. It mirrors the C++ object's API and thus is intuitively useable.</p> <p>The C++ <a href="qwebchannel.html">QWebChannel</a> API makes it possible to talk to any HTML client, which could run on a local or even remote machine. The only limitation is that the HTML client supports the JavaScript features used by <code>qwebchannel.js</code>. As such, one can interact with basically any modern HTML browser or standalone JavaScript runtime, such as node.js.</p> <p>There also exists a declarative <a href="qtwebchannel-qmlmodule.html">WebChannel API</a>.</p> </div> <p><b>See also </b><a href="qtwebchannel-standalone-example.html">Qt WebChannel Standalone Example</a> and <a href="qtwebchannel-javascript.html">JavaScript API</a>.</p> <!-- @@@QWebChannel --> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$blockUpdates-prop$$$blockUpdates$$$setBlockUpdatesbool$$$blockUpdatesChangedbool --> <h3 class="fn" id="blockUpdates-prop"><a name="blockUpdates-prop"></a><span class="name">blockUpdates</span> : <span class="type">bool</span></h3> <p>When set to true, updates are blocked and remote clients will not be notified about property changes.</p> <p>The changes are recorded and sent to the clients once updates become unblocked again by setting this property to false. By default, updates are not blocked.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>blockUpdates</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setBlockUpdates</b></span>(bool <i>block</i>)</td></tr> </table></div> <p><b>Notifier signal:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>blockUpdatesChanged</b></span>(bool <i>block</i>)</td></tr> </table></div> <!-- @@@blockUpdates --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QWebChannel[overload1]$$$QWebChannelQObject* --> <h3 class="fn" id="QWebChannel"><a name="QWebChannel"></a>QWebChannel::<span class="name">QWebChannel</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3> <p>Constructs the <a href="qwebchannel.html">QWebChannel</a> object with the given <i>parent</i>.</p> <p>Note that a <a href="qwebchannel.html">QWebChannel</a> is only fully operational once you connect it to a <a href="qwebchannelabstracttransport.html">QWebChannelAbstractTransport</a>. The HTML clients also need to be setup appropriately using <a href="qtwebchannel-javascript.html"><code>qwebchannel.js</code></a>.</p> <!-- @@@QWebChannel --> <!-- $$$~QWebChannel[overload1]$$$~QWebChannel --> <h3 class="fn" id="dtor.QWebChannel"><a name="dtor.QWebChannel"></a><code>[virtual] </code>QWebChannel::<span class="name">~QWebChannel</span>()</h3> <p>Destroys the <a href="qwebchannel.html">QWebChannel</a>.</p> <!-- @@@~QWebChannel --> <!-- $$$connectTo[overload1]$$$connectToQWebChannelAbstractTransport* --> <h3 class="fn" id="connectTo"><a name="connectTo"></a><code>[slot] </code><span class="type">void</span> QWebChannel::<span class="name">connectTo</span>(<span class="type"><a href="qwebchannelabstracttransport.html">QWebChannelAbstractTransport</a></span> *<i>transport</i>)</h3> <p>Connects the <a href="qwebchannel.html">QWebChannel</a> to the given <i>transport</i> object.</p> <p>The transport object then handles the communication between the C++ application and a remote HTML client.</p> <p><b>See also </b><a href="qwebchannelabstracttransport.html">QWebChannelAbstractTransport</a> and <a href="qwebchannel.html#disconnectFrom">QWebChannel::disconnectFrom</a>().</p> <!-- @@@connectTo --> <!-- $$$deregisterObject[overload1]$$$deregisterObjectQObject* --> <h3 class="fn" id="deregisterObject"><a name="deregisterObject"></a><span class="type">void</span> QWebChannel::<span class="name">deregisterObject</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3> <p>Deregisters the given <i>object</i> from the <a href="qwebchannel.html">QWebChannel</a>.</p> <p>Remote clients will receive a <code>destroyed</code> signal for the given object.</p> <p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See <a href="../qtcore/qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>.</p> <p><b>See also </b><a href="qwebchannel.html#registerObjects">QWebChannel::registerObjects</a>(), <a href="qwebchannel.html#registerObject">QWebChannel::registerObject</a>(), and <a href="qwebchannel.html#registeredObjects">QWebChannel::registeredObjects</a>().</p> <!-- @@@deregisterObject --> <!-- $$$disconnectFrom[overload1]$$$disconnectFromQWebChannelAbstractTransport* --> <h3 class="fn" id="disconnectFrom"><a name="disconnectFrom"></a><code>[slot] </code><span class="type">void</span> QWebChannel::<span class="name">disconnectFrom</span>(<span class="type"><a href="qwebchannelabstracttransport.html">QWebChannelAbstractTransport</a></span> *<i>transport</i>)</h3> <p>Disconnects the <a href="qwebchannel.html">QWebChannel</a> from the <i>transport</i> object.</p> <p><b>See also </b><a href="qwebchannel.html#connectTo">QWebChannel::connectTo</a>().</p> <!-- @@@disconnectFrom --> <!-- $$$registerObject[overload1]$$$registerObjectconstQString&QObject* --> <h3 class="fn" id="registerObject"><a name="registerObject"></a><span class="type">void</span> QWebChannel::<span class="name">registerObject</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>id</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3> <p>Registers a single object to the <a href="qwebchannel.html">QWebChannel</a>.</p> <p>The properties, signals and public methods of the <i>object</i> are published to the remote clients. There, an object with the identifier <i>id</i> is then constructed.</p> <p><b>Note: </b>A current limitation is that objects must be registered before any client is initialized.</p><p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See <a href="../qtcore/qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>.</p> <p><b>See also </b><a href="qwebchannel.html#registerObjects">QWebChannel::registerObjects</a>(), <a href="qwebchannel.html#deregisterObject">QWebChannel::deregisterObject</a>(), and <a href="qwebchannel.html#registeredObjects">QWebChannel::registeredObjects</a>().</p> <!-- @@@registerObject --> <!-- $$$registerObjects[overload1]$$$registerObjectsconstQHash<QString,QObject*>& --> <h3 class="fn" id="registerObjects"><a name="registerObjects"></a><span class="type">void</span> QWebChannel::<span class="name">registerObjects</span>(const <span class="type"><a href="../qtcore/qhash.html">QHash</a></span><<span class="type"><a href="../qtcore/qstring.html">QString</a></span>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *> &<i>objects</i>)</h3> <p>Registers a group of objects to the <a href="qwebchannel.html">QWebChannel</a>.</p> <p>The properties, signals and public invokable methods of the objects are published to the remote clients. There, an object with the identifier used as key in the <i>objects</i> map is then constructed.</p> <p><b>Note: </b>A current limitation is that objects must be registered before any client is initialized.</p><p><b>See also </b><a href="qwebchannel.html#registerObject">QWebChannel::registerObject</a>(), <a href="qwebchannel.html#deregisterObject">QWebChannel::deregisterObject</a>(), and <a href="qwebchannel.html#registeredObjects">QWebChannel::registeredObjects</a>().</p> <!-- @@@registerObjects --> <!-- $$$registeredObjects[overload1]$$$registeredObjects --> <h3 class="fn" id="registeredObjects"><a name="registeredObjects"></a><span class="type"><a href="../qtcore/qhash.html">QHash</a></span><<span class="type"><a href="../qtcore/qstring.html">QString</a></span>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *> QWebChannel::<span class="name">registeredObjects</span>() const</h3> <p>Returns the map of registered objects that are published to remote clients.</p> <p><b>See also </b><a href="qwebchannel.html#registerObjects">QWebChannel::registerObjects</a>(), <a href="qwebchannel.html#registerObject">QWebChannel::registerObject</a>(), and <a href="qwebchannel.html#deregisterObject">QWebChannel::deregisterObject</a>().</p> <!-- @@@registeredObjects --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>