QString与std::string的相互转换

Something Just Like This

 

 

 

//1 QString与int相互转换

QString qstr = QString::number(123);
int i = atoi(qstr.toStdString().c_str());

//也可以这样:
int i = atoi(qstr.ascii());

//2 QString与string,即std::string

string s = qstr.toStdString();
QString qstr2 = QString::fromStdString(s);


 

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