根据 http://doc.qt.io/qt-5/qtwebchannel-javascript.html
Furthermore keep in mind that only QML/C++ data types which can be converted to JSON will be (de-)serialized properly and thus accessible to HTML clients.
可以转换成JSON的数据类型有哪些? QJsonObject 或 QJsonDocument 是否包含在其中?
最佳答案
您可以查看类的文档,例如 QJsonValue和 QJsonObject并查看构造函数或 from*(...) 函数可以使用哪些类型和类,这些函数通常是静态的,需要 QVariant/QVariantHash/QVariantMap。
鉴于在 Qt JavaScript 中,数组可以转换为 QList<>,对象可以转换为 QVariantMap,我猜想这些(以及基本类型,如 int、float、string...)应该传递给 C++然后做成QJson(Value/Object/Array)。
根据您的需要,QJsonObject 可以格式化为类似于 this 的字符串。 .更多信息,JSON support in Qt .
关于javascript - QT 可以转换为 JSON 的 QML/C++ 数据类型有哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35346357/