QWebChannelAbstractTransport Class
C++QWebChannel 服务器与 HTML/JS 客户端之间的通信通道。更多内容...
| Header: | #include <QWebChannelAbstractTransport> |
| qmake: | QT += webchannel |
| Inherits: | QObject |
公共函数
| QWebChannelAbstractTransport(QObject *parent = nullptr) | |
| virtual | ~QWebChannelAbstractTransport() override |
公共插槽
| virtual void | sendMessage(const QJsonObject &message) = 0 |
信号
| void | messageReceived(const QJsonObject &message, QWebChannelAbstractTransport *transport) |
详细描述
QWebChannel 的用户必须实现此接口,并将该接口的实例连接到QWebChannel 服务器,以便每个应连接到QWebChannel 的客户端都能使用。Qt WebChannel 独立示例展示了如何使用以下方法实现此操作 Qt WebSockets。
注意: JSON 消息协议 被视为内部协议 ,未来可能会发生变更。
另请参阅 Qt WebChannel 独立示例。
成员函数文档
[explicit] QWebChannelAbstractTransport::QWebChannelAbstractTransport(QObject *parent = nullptr)
根据给定的parent ,创建一个传输对象。
[override virtual noexcept] QWebChannelAbstractTransport::~QWebChannelAbstractTransport()
销毁运输对象。
[signal] void QWebChannelAbstractTransport::messageReceived(const QJsonObject &message, QWebChannelAbstractTransport *transport)
当从远程客户端接收到新的 JSONmessage 时,必须发出此信号。transport 参数应设置为该传输对象。
[pure virtual slot] void QWebChannelAbstractTransport::sendMessage(const QJsonObject &message)
向远程客户端发送一个 JSONmessage 。具体实现会将该消息序列化,并将其传输到远程 JavaScript 客户端。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.