Ashish
Ashish

Reputation: 8529

how to convert unsigned char array to QByteArray in Qt?

unsigned char x[] = {0x7E,0x00,0x00,0x0F };

I want to push it to QByteArray but the QByteArray when finds '\0' stops copying.

Upvotes: 7

Views: 22382

Answers (2)

Fernie
Fernie

Reputation: 1

QByteArray test("\xa4\x00\x00", 3);

Upvotes: 0

RedX
RedX

Reputation: 15175

Which Qt version are you using? 4.7 has QByteArray(const char*, size) which should work and QByteArray::fromRawData(const char*, int size) which also should work.

Upvotes: 11

Related Questions