qt中int,string,qstring,uint32_t,quuid相互转换

//int和stirng
int x;
string str;
x=atoi(str.c_str());
str=to_string(x);

//qstring和string相互转换
QString x;
string xx;
xx=QString(x).toLocal8Bit().data();
x=QString::fromLocal8Bit((xx).c_str());

//uint32_t和string
uint32_t x;
string str;
str=to_string(x);
x=atoi(str.c_str());

//quuid转string
//quuid得先和qstring相互转才可以
QUuid id;
QString strId;
string str;
strId = id.toString();//先转成qstring
str= strId.toStdString();//再转成stdstring
//同理string得先转换成qstring再转为quuid
id=Uuid(strId);

// int和QString
QString str("100");
int tmp = str.toInt();
int tmp = 100;
QString str = QString::number(tmp);

你可能感兴趣的:(C/C++/qt,qt)