diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2022-10-26 20:05:28 +0200 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2023-02-09 17:19:50 +0100 |
commit | 4b5949bf54aa84eea866da9eb8d0b6834c968282 (patch) | |
tree | 77c18eef7e35b692977bf1dfcd6dc93c7e40c006 /src/webchannel/qwebchannel.cpp | |
parent | 48d2066d6c9b38f29368e5205a5b7f49ab3fa857 (diff) | |
download | qtwebchannel-4b5949bf54aa84eea866da9eb8d0b6834c968282.tar.gz |
Add server-side support for custom converters
Automatically tries to convert server-side values to/from QJsonValue.
Carries on as usual when the conversion fails.
Fixes: QTBUG-92902
Change-Id: I89ae7c3bc8490223c9fab41ca513d9277483692e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/webchannel/qwebchannel.cpp')
-rw-r--r-- | src/webchannel/qwebchannel.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/webchannel/qwebchannel.cpp b/src/webchannel/qwebchannel.cpp index 60e49e3..54a5c0b 100644 --- a/src/webchannel/qwebchannel.cpp +++ b/src/webchannel/qwebchannel.cpp @@ -33,6 +33,12 @@ QT_BEGIN_NAMESPACE QWebChannel transparently supports QFuture. When a client calls a method that returns a QFuture, QWebChannel will send a response with the QFuture result only after the QFuture has finished. + Custom conversion of types to and from JSON is supported by defining converters with + QMetaType::registerConverter() to and from QJsonValue. Note that custom converters from QJsonValue to a concrete + type must fail if the QJsonValue does not match the expected format. Otherwise QWebChannel cannot fall back to its + default conversion mechanisms. + Custom converters are also available on \l{Qt WebChannel JavaScript API}{the JavaScript side}. + The C++ QWebChannel API makes it possible to talk to any HTML client, which could run on a local or even remote machine. The only limitation is that the HTML client supports the JavaScript features used by \c{qwebchannel.js}. As such, one can interact @@ -40,7 +46,8 @@ QT_BEGIN_NAMESPACE There also exists a declarative \l{Qt WebChannel QML Types}{WebChannel API}. - \sa {Qt WebChannel Standalone Example}, {Qt WebChannel JavaScript API}{JavaScript API} + \sa {Qt WebChannel Standalone Example}, {Qt WebChannel JavaScript API}{JavaScript API}, + QMetaType::registerConverter() */ /*! |