QByteArray makes a deep copy of the const char * data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use QByteArray::fromRawData() instead.)
at() can be faster than operator[](), because it never causes a deep copy to occur.
A QByteArray can embed ' ' bytes. The size() function always returns the size of the whole array, including embedded ' ' bytes. If you want to obtain the length of the data up to and excluding the first ' ' character, call qstrlen() on the byte array.
After a call to resize(), newly allocated bytes have undefined values. To set all the bytes to a particular value, call fill().
To obtain a pointer to the actual character data, call data() or constData(). These functions return a pointer to the beginning of the data. The pointer is guaranteed to remain valid until a non-const function is called on the QByteArray. It is also guaranteed that the data ends with a ' ' byte unless the QByteArray was created from a raw data. This ' ' byte is automatically provided by QByteArray and is not counted in size().
When you append() data to a non-empty array, the array will be reallocated and the new data copied to it. You can avoid this behavior by calling reserve(), which preallocates a certain amount of memory. You can also call capacity() to find out how much memory QByteArray actually allocated. Data appended to an empty array is not copied.
If you want to find all occurrences of a particular character or substring in a QByteArray, use indexOf() or lastIndexOf(). The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:
MadEdit-0.2.9.1 今天终于摆了UltraEdit
还是用这惯。还是要UE