WebChannel QML Type
QML interface to QWebChannel. More...
Import Statement: | import QtWebChannel 1.8 |
Properties
- blockUpdates : bool
- propertyUpdateInterval : int
- registeredObjects : list<QtObject>
- transports : list<QtObject>
Attached Properties
- id : string
Methods
- void connectTo(QtObject transport)
- void deregisterObject(QtObject object)
- void disconnectFrom(QtObject transport)
- void registerObject(const string id, QtObject object)
- void registerObjects(object objects)
Detailed Description
The WebChannel provides a mechanism to transparently access QObject or QML objects from HTML clients. All properties, signals and public slots can be used from the HTML clients.
See also QWebChannel and JavaScript API.
Property Documentation
blockUpdates : bool |
When set to true
, updates are blocked and remote clients will not be notified about property changes.
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.
propertyUpdateInterval : int |
The property update interval.
This interval can be changed to a different interval in milliseconds by setting it to a positive value. Property updates are batched and sent out after the interval expires. If set to zero, the updates occurring within a single event loop run are batched and sent out on the next run. If negative, updates will be sent immediately. Default value is 50 milliseconds.
A list of objects which should be accessible to remote clients.
The objects must have the attached id property set to an identifier, under which the object is then known on the HTML side.
Once registered, all signals and property changes are automatically propagated to the clients. Public invokable methods, including slots, are also accessible to the clients.
If one needs to register objects which are not available when the component is created, use the imperative registerObjects method.
See also registerObjects() and id.
A list of transport objects, which implement QWebChannelAbstractTransport. The transports are used to talk to the remote clients.
See also connectTo() and disconnectFrom().
Attached Property Documentation
WebChannel.id : string |
The identifier under which an object, registered to a WebChannel, is known to remote clients.
This property must be set for every object that should be published over the WebChannel. While no restrictions are enforced on the format of the id, it is usually a good idea to choose a string that is also a valid JavaScript identifier.
Method Documentation
void connectTo(QtObject transport) |
Connects to the transport, which represents a communication channel to a single client.
The transport object must be an implementation of QWebChannelAbstractTransport.
See also transports and disconnectFrom().
void deregisterObject(QtObject object) |
Deregisters the given object from the WebChannel.
Remote clients will receive a destroyed
signal for the given object.
See also registerObjects(), registerObject(), and registeredObjects.
void disconnectFrom(QtObject transport) |
Disconnects the transport from this WebChannel.
The client will not be able to communicate with the WebChannel anymore, nor will it receive any signals or property updates.
See also connectTo().
Registers a single object to the WebChannel.
The properties, signals and public methods of the object are published to the remote clients. There, an object with the identifier id is then constructed.
A property that is BINDABLE
but does not have a NOTIFY
signal will have working property updates on the client side, but no mechanism to register a callback for the change notifications.
Note: A current limitation is that objects must be registered before any client is initialized.
See also registerObjects(), deregisterObject(), and registeredObjects.
void registerObjects(object objects) |
Registers the specified objects to make them accessible to HTML clients. objects should be a JavaScript Map object. The key of the map is used as an identifier for the object on the client side.
Once registered, all signals and property changes are automatically propagated to the clients. Public invokable methods, including slots, are also accessible to the clients.
This imperative API can be used to register objects on the fly. For static objects, the declarative registeredObjects property should be preferred.
See also registeredObjects.