QByteArray

来源:互联网 发布:java 日志服务器搭建 编辑:程序博客网 时间:2024/05/23 01:56
Qt助手上有这样一段代码
int QByteArray::size() const
Returns the number of bytes in this byte array.

The last byte in the byte array is at position size() - 1. In addition, QByteArray ensures that the byte at position size() is always '\0', so that you can use the return value of data() and constData() as arguments to functions that expect '\0'-terminated strings. If the QByteArray object was created from a raw data that didn't include the trailing null-termination character then QByteArray doesn't add it automaticall unless the deep copy is created.

Example:

QByteArray ba("Hello");
int n = ba.size();          // n == 5
ba.data()[0];               // returns 'H'
ba.data()[4];               // returns 'o'
ba.data()[5];               // returns '\0'
See also isEmpty() and resize().

QList<QByteArray> QByteArray::s


QByteArray qbaData = "11111111111111111111100100010111111111111111111111";
QString qstrTemp = QString(qbaData);