[英]Qt: Display byte from QByteArray
这可能是一个愚蠢的问题,但例如,我似乎找不到如何显示QByteArray中的字节为“ 01011000”的信息。
That's because the function is not related to the scope of QByteArray
, which is a simple byte container. 这是因为该函数与
QByteArray
的范围无关, QByteArray
是一个简单的字节容器。 Instead, you need to get the specific byte (as char
) to print and show singles bits from it. 取而代之的是,您需要获取特定的字节(如
char
)以进行打印并显示其中的单字节位。 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). 假设您的计算机有8位字节(这不是20年前的粗体语句)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.