WebChannel QML 类型

QML 接口到 QWebChannel . 更多...

import 语句: import QtWebChannel 1.7

特性

附加特性

方法

详细描述

WebChannel 提供机制去透明访问 QObject 或 QML 对象从 HTML 客户端。,所有特性、信号及公共槽都可以被使用,从 HTML 客户端。

另请参阅 QWebChannel and JavaScript API .

特性文档编制

registeredObjects : QQmlListProperty < QObject > [read-only]

远程客户端应该可以访问的对象列表。

对象必须拥有附加 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 方法。

另请参阅 registerObjects () 和 id .

transports : QQmlListProperty < QObject > [read-only]

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

另请参阅 connectTo () 和 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 )

连接到 transport ,表示到单个客户端的通信通道。

The transport object must be an implementation of QWebChannelAbstractTransport .

另请参阅 transports and disconnectFrom ().

void disconnectFrom ( QWebChannelAbstractTransport transport )

断开连接 transport 从此 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 对象 )

注册指定 对象 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 .