- Qt 5.15
- Qt WebChannel
- QML Types
- WebChannel QML Type
- Qt 5.15.16 Reference Documentation

# WebChannel QML Type

QML interface to QWebChannel. More...

Import Statement: | import QtWebChannel 1.15
Since: | Qt 5.4

- List of all members, including inherited members

## Properties

- registeredObjects : QQmlListProperty<QObject>
- transports : QQmlListProperty<QObject>

## Attached Properties

- id : QString

## Methods

- void connectTo(QWebChannelAbstractTransport transport)
- void disconnectFrom(QWebChannelAbstractTransport transport)
- void registerObjects(QVariantMap 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

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.

See also registerObjects() and id.

transports : QQmlListProperty<QObject>

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 : 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.

## Method Documentation

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.

See also 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.

See also connectTo().

void registerObjects(QVariantMap objects)

Registers the specified 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.

See also registeredObjects.