1 #include <QCoreApplication> 2 #include <QString> 3 4 int main(int argc, char *argv[]) 5 { 6 QCoreApplication a(argc, argv); 7 8 int number = 123; // 例子中的整数 9 10 // 将整数转换为16进制字符串 11 QString hexString = QString::number(number, 16); 12 13 // 确保16位长度,不足时在前面补0 14 hexString = hexString.rightJustified(16, '0'); 15 16 // 检查第八位是否为1 17 if (hexString.at(7) == QLatin1Char('1')) { 18 qDebug() << "第八位是1"; 19 } else { 20 qDebug() << "第八位不是1"; 21 } 22 23 return a.exec(); 24 }
标签:Qt,16,int,hexString,检查,number,QString From: https://www.cnblogs.com/ybqjymy/p/18095912