Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 1.33 KB

README.md

File metadata and controls

25 lines (17 loc) · 1.33 KB

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