What does QByteArray convert to QML?

if I have

signal: void foo(QByteArray data); 

And in QML I process it:

  onFoo: { console.log(data.toString()); } 

What is the data type in QML? What are his methods? This doesn't seem to be a javascript string - it doesn't even have .length , and not .charCodeAt() . But it also doesn't look like QByteArray - no .at() . data[0] undefined ! It has .toString() .

How do I access its contents? For instance. if it's a four-byte uint32_t, how do I get that number in a javascript variable?

+6
source share
2 answers

According to http://doc.qt.io/qt-5/qtqml-cppintegration-data.html and the current source http://code.woboq.org/qt5/qtdeclarative/src/qml/compiler/qqmltypecompiler.cpp .html # 567 , there is no conversion between QByteArray to QML. You will probably get an opaque, unique object in JS.

+3
source

As stated in here :

The QML mechanism provides automatic type conversion between QByteArray values ​​and JavaScript ArrayBuffer objects.

This feature is available with Qt 5.8.

0
source

Source: https://habr.com/ru/post/988580/


All Articles