Qt下保存无符号单字节数据并将之转化为int型

#include <QtCore/QCoreApplication>
#include<QDebug>
#include <QVariant>
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    unsigned char df=0xff;
    int b=QVariant(df).toInt();
    qDebug("b is %d and %x",b,b);
    return a.exec();
}


输出为:

 

b is 255 and ff

你可能感兴趣的:(Qt下保存无符号单字节数据并将之转化为int型)