Closed GoogleCodeExporter closed 8 years ago
No, this has nothing with QextSerialPort.
If you want to construct an QByteArray which contians a bytes stream likes
this: "\x00\x00\x00\x00\x00"
You should write
QByteArray("\x00\x00\x00\x00\x00", 5);
instead of
QByteArray("\x00\x00\x00\x00\x00");
Original comment by dbzhang...@gmail.com
on 10 Nov 2011 at 1:44
> You should write
> QByteArray("\x00\x00\x00\x00\x00", 5);
No, this won't work. Two QByteArrays one created by
QByteArray("\x00\x00\x00\x00\x00");
the other created by
QByteArray("\x00\x00\x00\x00\x00", 5);
contain the same data.
So a call to QByteArray.constdata() will return an emtpy String "" in both
cases and nothing gets written.
The solution is to use the QIODevice.write(const char *data, int size); method
which doesn't care about the content found at the const char *data pointer.
Eberhard
Original comment by eberhard...@gmail.com
on 10 Nov 2011 at 12:00
But as I said in my first post; i don't think this is a bug or defect , rather
a coding gotcha for noobs like me.
Original comment by eberhard...@gmail.com
on 10 Nov 2011 at 12:01
No, you are wrong.
QByteArray("\x00\x00\x00\x00\x00");
equals
QByteArray("\x00\x00\x00\x00\x00", strlen("\x00\x00\x00\x00\x00"));
equals
QByteArray("\x00\x00\x00\x00\x00", 0);
Original comment by dbzhang...@gmail.com
on 11 Nov 2011 at 6:03
Original comment by dbzhang...@gmail.com
on 16 Mar 2012 at 9:03
Original issue reported on code.google.com by
eberhard...@gmail.com
on 19 Oct 2011 at 3:17