Using QByteArray

From Qt Wiki
Revision as of 13:21, 22 November 2016 by EdwardWelbourne (talk | contribs) (Add to relevant category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

QByteArray is the Qt class to store a array of bytes. It is analogous to a char *. Unlike a QString, a QByteArray has no encoding information and makes no attempt to decode bytes into characters.

Converting QByteArray to QString

To convert a QByteArray to QString, one needs to specify the encoding. It is not possible to convert a QByteArray to QString without knowing the encoding. Once the encoding is known, one can use functions like QString::fromUtf8, QString::fromUcs4 or use QTextCodec::toUnicode().

QByteArray::fromRawData()

No copy. Copies point to raw data.

QByteArray::constData