WebChannel QML Type

QML interface to QWebChannel. 更多...

Import Statement: import QtWebChannel 1.0
开始支持版本: Qt 5.4

属性

Attached Properties

  • id : QString

方法

详细描述

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.

参见 QWebChannel and JavaScript API.

属性

registeredObjects : QQmlListProperty<QObject>

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.

参见 registerObjects() and id.


transports : QQmlListProperty<QObject>

A list of transport objects, which implement QWebChannelAbstractTransport. The transports are used to talk to the remote clients.

参见 connectTo() and disconnectFrom().


附加属性

WebChannel.id : QString

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.


成员

void connectTo(QWebChannelAbstractTransport transport)

Connects to the transport, which represents a communication channel to a single client.

The transport object must be an implementation of QWebChannelAbstractTransport.

参见 transports and disconnectFrom().


void disconnectFrom(QWebChannelAbstractTransport 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.

参见 connectTo().


void registerObjects(QVariantMap objects)

Registers objects to make them accessible to HTML clients. 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.

参见 registeredObjects.