Hi Alejandro, Thanks for your suggestion. I made it all working with the string.
On Fri, Nov 21, 2014 at 3:54 PM, Alejandro Exojo <[email protected]> wrote: > El Friday 21 November 2014, Nilesh Kokane escribió: > > Hi, > > > > I'm accessing the Qbytearray from c++ in the qml code and assigning it > to > > a property real ,but getting error while run as *qrc:///main.qml:65: > Error: > > Cannot assign [undefined] to double*. > > A "real" in QML is a double in C++. How do you expect a QByteArray to be > converted to a real? There is a QByteArray::toFloat, but that's "interpret > the > byte array as text, and parse it as a float". If you are reading binary > data > that is not going to work. > > The closest representation of the original QByteArray would be a string, > since > can be seen as a string of bytes, and IIRC, you can use whatever byte > value in > a JavaScript string. > > $ node > > byteArray = '\x02hi!\x03\x00' > '\u0002hi!\u0003\u0000' > > byteArray.length > 6 > > for (var i=0; i < byteArray.length; i++) { > ... console.log(byteArray.charCodeAt(i)); > ... } > 2 > 104 > 105 > 33 > 3 > 0 > > > I've registered the c++ class in the main by > > qmlRegisterType<MainWindow>("serial", 1, 0, "serialdata"); and imported > the > > serial 1.0 in the qml file. Am i wrong somewhere. > > You've got an error on the QML file, line 65. This line of the C++ side is > not > very useful. > > -- > Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2 > http://barnacity.net/ | http://disperso.net > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest > -- Nilesh
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
