QVariant::DataPtr is private, and yesterday I used QBitArray to do some work. There’s a function data_ptr() returning DataPtr&, but I don’t know when and how to use this function. I write the returning data to a file and opened it in ST2, there shows an SOH:
int main()
{
QBitArray bit(8);
bit[5] = true; //--> I tried bit[7] = true; result is `SOH` still
QFile file("out");
file.open(QIODevice::WriteOnly);
QDataStream outs(&file);
outs << bit.data_ptr();
file.close();
return 0;
}
I know SOH is the meaning of Start Of Header, and it is defined as 0x01(1byte) for frame delimiting. First I wrote bit[7]=true; so I thought bit.data_ptr() may be the raw data(00000001 in binary) in bit which is an encapsulated QBitArray. But when I tried bit[5]=true; and opened the file in ST2, it still shew SOH. So I’m confused.

DataPtr is just a pointer to Data structure. The structure is made private, so you shouldn’t use it for anything. However, you can use pointer to it to discriminate two byte arrays. Use QBitArray::operator<<() to write bit array into a data stream.