如果在您的情况下不起作用,那么其他事情就会出错。 (这是其他评论家已经告诉你的。)
我怎么能说服你呢?
我最后的(绝望)尝试:一个(不那么)MCVE:
#include
#include
int main()
{
QString samples[] = {
"0x0", "0x1", "0x1e", "0x11", "0x1111", "0x111e", "0x111f"
};
enum { n = sizeof samples/sizeof *samples };
for (int i = 0; i < n; ++i) {
const QString &hexString = samples[i];
qDebug() << "Formatted binary output of " << hexString;
for (int j = 1; j < 40; j += 8) {
bool ok;
qDebug()
<< QString("%1: %2")
.arg(j, 2)
.arg(hexString.toULongLong(&ok, 16), j, 2, QChar('0'));
}
}
// done
return 0;
}
编译和测试