### Introduction
The Qt WebChannel module offers Qt applications a seamless way to publish `QObjects` for interaction
with HTML/JavaScript clients. These clients can either be inside local Qt `WebView`s or any other,
potentially remote, client which supports JavaScript, as long as a communication channel such
as WebSocket is available.
Qt WebChannel uses introspection on the `QObject`s and sends this serialized data to the clients.
There, with the help of a small JavaScript library, an object is created which simulates the API of
the `QObject`. Any invokable methods, including slots, can be called as well as properties read and
written. Additionally you can connect to signals and register JavaScript callbacks as handlers.
### Dependencies
This module depends on Qt Core only. Optionally, an additional plugin for Qt Quick can be built, which
makes it easy to use a `QWebChannel` from QML. Note that this module alone is not functional. It
is being used in e.g. Qt WebKit to provide a seamless integration of QML/C++ QObjects into JavaScript
clients. You can integrate it in your projects as well, by providing an implementation of the
`QWebChannelAbstractTransport` class, see the `standalone` example for how to do this.
### Building
qmake-qt5
make
make install
### Usage from C++
To use the Qt/C++ library, add the following to your `QMake` project:
QT += webchannel
Then, in your C++ code, construct a webchannel, then publish your `QObject`s:
QWebChannel channel;
channel.registerObject(QStringLiteral("foo"), myFooObj);
....
Additionally, you need to provide a communication channel to the HTML client. One way is to
use the Qt WebSockets module. On the HTML/JavaScript client side, you need to embed
`src/webchannel/qwebchannel.js` and setup the connection to a client-side transport. An example
which shows all this in action can be found in `examples/standalone`.
### Usage from Qt Quick
For QML applications, use the following import:
import QtWebChannel 1.0
Then setup the WebChannel, register objects to it and connect to transport objects:
WebChannel {
registeredObjects: [foo, bar, ...]
transports: [yourTransport]
}
To see this in action, take a look at the test code in `tests/auto/qml`.
没有合适的资源?快使用搜索试试~ 我知道了~
qtwebchannel-everywhere-src-5.15.0.zip
共165个文件
h:28个
pro:18个
cpp:17个
需积分: 5 0 下载量 78 浏览量
2024-03-02
21:18:57
上传
评论
收藏 546KB ZIP 举报
温馨提示
qtwebchannel-everywhere-src-5.15.0
资源推荐
资源详情
资源评论
收起资源包目录
qtwebchannel-everywhere-src-5.15.0.zip (165个子文件)
changes-5.7.0 2KB
changes-5.5.0 2KB
changes-5.14.0 1KB
changes-5.8.0 1KB
changes-5.13.0 1002B
changes-5.11.0 965B
changes-5.10.0 963B
changes-5.9.0 956B
changes-5.6.0 947B
changes-5.12.0 730B
changes-5.15.0 730B
changes-5.7.1 1KB
changes-5.10.1 1KB
changes-5.11.1 991B
changes-5.9.1 984B
changes-5.6.1 947B
changes-5.13.1 756B
changes-5.14.1 756B
changes-5.12.1 755B
changes-5.9.2 1KB
changes-5.12.2 1KB
changes-5.11.2 1006B
changes-5.13.2 771B
changes-5.14.2 771B
changes-5.6.3 1KB
changes-5.9.3 985B
changes-5.12.3 771B
changes-5.11.3 770B
changes-5.9.4 987B
changes-5.12.4 771B
changes-5.9.5 985B
changes-5.12.5 771B
changes-5.9.6 999B
global.cfg 98B
.qmake.conf 75B
tst_webchannel.cpp 41KB
qmetaobjectpublisher.cpp 38KB
qqmlwebchannel.cpp 11KB
qwebchannel.cpp 9KB
chatserver.cpp 5KB
websockettransport.cpp 5KB
main.cpp 4KB
main.cpp 4KB
websocketclientwrapper.cpp 4KB
qwebchannelabstracttransport.cpp 4KB
dialog.cpp 3KB
qqmlwebchannelattached.cpp 3KB
plugin.cpp 3KB
testobject.cpp 2KB
testtransport.cpp 2KB
qml.cpp 2KB
testwebchannel.cpp 2KB
LICENSE.FDL 23KB
LICENSE.GPL2 18KB
LICENSE.GPL3 35KB
LICENSE.GPL3-EXCEPT 36KB
qmetaobjectpublisher_p.h 12KB
signalhandler_p.h 12KB
tst_webchannel.h 10KB
qqmlwebchannel.h 4KB
chatserver.h 4KB
core.h 3KB
qwebchannel.h 3KB
websockettransport.h 3KB
websocketclientwrapper.h 3KB
dialog.h 3KB
qqmlwebchannelattached_p.h 3KB
qwebchannel_p.h 3KB
variantargument_p.h 3KB
qwebchannelabstracttransport.h 3KB
qwebchannelglobal.h 2KB
testobject.h 2KB
testtransport.h 2KB
testwebchannel.h 2KB
qtwebchannelversion.h 228B
qqmlwebchannelattached_p.h 68B
qmetaobjectpublisher_p.h 66B
qwebchannelabstracttransport.h 63B
variantargument_p.h 61B
signalhandler_p.h 59B
qwebchannel_p.h 57B
qwebchannelglobal.h 52B
qqmlwebchannel.h 49B
qwebchannel.h 46B
chatclient.html 5KB
index.html 3KB
qwebchannel.js 17KB
qwclient.js 6KB
chatclient.js 6KB
package.json 430B
package.json 242B
configure.json 34B
dependencies.json 6B
LICENSE.LGPL3 8KB
README.md 2KB
standalone-screenshot.png 30KB
chatclient-html.png 7KB
chatserver-cpp.png 7KB
chatclient-qml.png 5KB
exampleassets.pri 628B
共 165 条
- 1
- 2
资源评论
weixin_44472541
- 粉丝: 0
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功