Skip to content
An implementation of Qt's WebChannel protocol in C++14
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include/webchannelpp
LICENSE.GPL2
LICENSE.LGPL3
README.md

README.md

WebChannel++

What is WebChannel++?

WebChannel++ is an implementation of Qt's WebChannel protocol in C++14. WebChannel++ is header-only and depends only on standard library features and Niels Lohmann's excellent JSON Library for C++.

Usage

To use it, you will have to define your own Transport subclass to handle the network related tasks (sending and receiving messages). An examplary implementation based on the standalone asio library is included in asio_transport.h. This implementation communicates via TCP/IP and expectes messages to be newline-delimited.

Caveats

QObject marshalling

Due to some restrictions in nlohmann::json, plain pointers to objects can't be marshalled to or from json. To circumvent this, WebChannel++ defines the transparent pointer class QObject::Ptr. It acts and behaves just like a QObject* (and can implicitly be converted to and from QObject*), but is a separate type which can be marshalled to and from nlohmann::json.

In practice, you only have to care about this when you retrieve a property or a get the return value from a method:

// WebChannelPP::QObject *value = obj->property("value");  // WRONG!
WebChannelPP::QObject::Ptr value = obj->property("value");  // correct
You can’t perform that action at this time.