WebChannel QML 类型

QML 接口到 QWebChannel . 更多...

import 语句: import QtWebChannel 1.8

特性

附加特性

方法

详细描述

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

另请参阅 QWebChannel and JavaScript API .

特性文档编制

blockUpdates : bool

当设为 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.

registeredObjects : list < QtObject > [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 : list < QtObject > [read-only]

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

另请参阅 connectTo () 和 disconnectFrom ().

附加特性文档编制

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.

方法文档编制

void connectTo ( QtObject transport )

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

The transport object must be an implementation of QWebChannelAbstractTransport .

另请参阅 transports and disconnectFrom ().

void deregisterObject ( QtObject object )

撤销注册给定 object from the WebChannel.

远程客户端会接收 destroyed 信号对于给定对象。

另请参阅 registerObjects (), registerObject (),和 registeredObjects .

void disconnectFrom ( QtObject 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 registerObject (const string id , QtObject object )

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 然后被构造。

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.

注意: 当前的限制是对象被注册,在任何客户端被初始化之前。

另请参阅 registerObjects (), deregisterObject (),和 registeredObjects .

void registerObjects ( 对象 对象 )

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

另请参阅 registeredObjects .