Questions tagged [qbytearray]

A QByteArray is a class from the Qt toolkit which provides an array of bytes.

QByteArray is meant to replace char * arrays. It can hold both raw bytes, and 8-bit null-terminated strings. QByteArray is initialized as easy as this:

QByteArray myArray("Hello, world!");

It also makes sure that the string is always null-terminated.

QByteArray supports indexed and iterator-based access, as well as it has methods like append() or prepend(), replace(), and other of the kind.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

267 questions
-1
votes
2 answers

Appending one QByteArray to another QByteArray

I wrote the following function, which is supposed to allow me to append some input QByteArray data to a private QByteArray inside of my class: void addQByteArray(QByteArray* array) { p_commandArray.append(array); } My understanding is that the…
Jason O
  • 753
  • 9
  • 28
-1
votes
1 answer

Display value of QByteArray

I am making simple serial communication app. Connection works well and I send data from my device to my app i am getting in log when I do qDebug() << dataByte: "\x0B" "\x0B" Now I want to display this in a QTextEdit as "0B" string. How do I go…
GeneCode
  • 7,545
  • 8
  • 50
  • 85
-1
votes
1 answer

QbyteArray data split

I have an array with size of n. I want to split this array with size of y. It need to be x times newarray with size of y. I need multidimensional array like myarray[x][y]. Output need to be myarray[0][0...y],myarray[1][0...y],....myarray[x][0...y].…
Cenk
  • 1
  • 2
-1
votes
1 answer

No matching function for call to 'QString::fromLatin1(QByteArray*&)'

I have a class A that calls class B after a signal is emitted. When the user closes B, I am trying to transfer a QString value from B to A. To do so, I first convert the QString to a QByteArray, then I am exchanging the QByteArray between classes.…
WKstraw
  • 67
  • 1
  • 13
-1
votes
1 answer

QByteArray::append() leads to unexpected QByteArray sizes

QByteArray array; union { char bytes[sizeof(float)]; float value; } myFloat; for (int i = 0; i < 10; i++) { myFloat.value = 2.3 + i; array.append(myFloat.bytes); qDebug() << array.length(); //9, 18, 27, etc, instead of 4, 8, 12,…
Daan R
  • 58
  • 9
-1
votes
1 answer

Why is the QByteArray read from a file smaller than the newly downloaded QByteArray?

I am attempting to compare a QByteArray of an already saved html file with a QByteArray that was just downloaded. I have to convert the QString of the file's contents to QByteArray in order to compare them (or vice versa) and comparing bytes seems…
seang96
  • 61
  • 1
  • 11
-2
votes
2 answers

XOR gone wrong with its output when using a QByteArray

Recently, I created a small XOR checksum which allegedly worked (or at least in my head it did). I do not know what I have done wrong as I am following the exact same logic I used, when I have did it in C#/Java. At the moment, it outputs rubbish…
Joe Carr
  • 445
  • 1
  • 10
  • 23
-2
votes
1 answer

Is this code send hex data in correct way in Qt C++?

I am new to Qt.I am working on finger print madoule with this document. I want to send my data to serial port in this format: I wrote my code in this format, but I think my data has mistake, because this code turn on the LED in some device: …
MHM
  • 261
  • 1
  • 2
  • 15
-2
votes
1 answer

Convert char to bytearray with hex-data 0x31

I work with QT Creator (MinGW 5.3.0 C++, Windows) and want to write some serial-connection hex-data. I found a way but there is something wrong. Only one hex-data he convert wrong. I hope my code will help to understand. static const unsigned char…
knowless
  • 13
  • 6
-3
votes
1 answer

Why doesn't `unique_ptr` degrade to `QByteArray*`?

I have the following code: msg_buf_ptr = std::make_unique(); return QDataStream{msg_buf_ptr, QIODevice::WriteOnly}; I am getting the following error: no known conversion for argument 1 from ‘std::unique_ptr’ to…
Kyle Strand
  • 15,941
  • 8
  • 72
  • 167
-4
votes
1 answer

how to convert QByteArray to Array in qt?

i have a QByteArray variable like this: QByteArray read= port->readAll(); now i want convert read to Array for write binary file like this: int b[] = {}; // lengh of array is port->readAll() size QFile…
-4
votes
1 answer

Loading png image texture from char array or QByteArray with libpng

I have the image data as QByteArray. I want to load the texture of this image from that data using libpng. Everywhere I see reading the image texture from the file or from input stream. But how can I load the image from the QByteArray?? Thanks.
Tahlil
  • 2,680
  • 6
  • 43
  • 84
1 2 3
17
18