SKINDER
SKINDER

Reputation: 1020

How to convert from BYTE* to QString?

I have a DATA_BLOB structure but I need to convert it to QString. How can I do this?

Upvotes: 1

Views: 7020

Answers (3)

Yash
Yash

Reputation: 7064

   BYTE* pu8_RawData = (BYTE*)i_RawData.parray->pvData;
   DWORD u32_RawLen  =        i_RawData.parray->rgsabound[0].cElements;

   qDebug() << QString(QByteArray((const char*) pu8_RawData, (int)u32_RawLen));

Upvotes: 0

Cătălin Pitiș
Cătălin Pitiș

Reputation: 14327

BYTE* myByteBlob; 
int myByteBlobSize;

// Get the blob, find out the size.
// ...

QString myString( QByteArray( myByteBlob, myByteBlobSize));

Upvotes: 0

Patrice Bernassola
Patrice Bernassola

Reputation: 14446

You can use the QString constructor with a QByteArray parameter. You can use too the constructor with the const char* parameter too

Hope that helps

Upvotes: 1

Related Questions