2
0
Fork
You've already forked qtwebchannel
0
No description
  • C++ 71.5%
  • QML 18.8%
  • JavaScript 6.4%
  • CMake 3%
  • C 0.3%
Qt Submodule Update Bot 0933fb9e22 Update dependencies on 'dev' in qt/qtwebchannel
Change-Id: Id21767b6850c2bb0c7fd9c985aaed9343a6feb6e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2026年07月09日 20:08:19 +00:00
coin Remove unnecessary comment 2025年03月05日 16:07:18 +01:00
dist Remove year from Qt Copyright in REUSE.toml 2025年07月09日 10:59:48 +02:00
examples Make Qt WebChannel examples self-contained 2026年06月19日 14:18:37 +00:00
LICENSES Add REUSE.toml files and missing licenses 2024年11月05日 09:58:01 +01:00
src Doc: Add alternate text for Qt WebChannel images 2026年06月18日 10:05:46 +00:00
tests Port Q_ENUMS to Q_ENUM 2025年12月08日 21:30:18 +00:00
.cmake.conf Bump version to 6.13.0 2026年06月04日 21:59:59 +00:00
.gitattributes Add gitattributes and gitignore files. 2013年12月20日 13:01:06 +01:00
.gitignore Add .tag file and fix .gitignore 2014年07月02日 14:40:18 +02:00
.gitreview Add .gitreview file 2025年03月24日 14:21:52 +00:00
.tag Add .tag file and fix .gitignore 2014年07月02日 14:40:18 +02:00
CMakeLists.txt Move qt_internal_project_setup as early as possible 2025年06月20日 15:42:52 +02:00
CONTRIBUTING.md Add CONTRIBUTING.md file 2026年04月21日 07:20:51 +00:00
dependencies.yaml Update dependencies on 'dev' in qt/qtwebchannel 2026年07月09日 20:08:19 +00:00
licenseRule.json Add CONTRIBUTING.md file 2026年04月21日 07:20:51 +00:00
README.md Fixup documentation issues. 2014年08月04日 14:52:07 +02:00
REUSE.toml Add CONTRIBUTING.md file 2026年04月21日 07:20:51 +00:00

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 WebViews 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 QObjects 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 QObjects:

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.