这可能是一个愚蠢的问题,但例如,我似乎找不到如何显示QByteArray中的字节为“ 01011000”的信息。
That's because the function is not related to the scope of QByteArray
, which is a simple byte container. Instead, you need to get the specific byte (as char
) to print and show singles bits from it. For instance, try this (magic):
char myByte = myByteArray.at(0);
for (int i = 7; i >= 0; --i) {
std::cout << ((myByte >> i) & 1);
}
Assuming that your machine has 8-bit bytes (which is not as a bold statement as it would have been 20 years ago).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.