QString、char*、std::string和int的转换

直接上货,不墨迹!

QString   str_QString;
std::string str_string;
char      *_pChar;
int           a;

1、

str_QString = str_string.c_str();
str_QString = QString(_pChar);
str_QString = QString::number(a);

2、

str_string = str_QString.toStdString;
str_string = str_QString.local8Bit();
str_string = _pChar;

3、

_pChar = str_string.c_str();
_pChar = (const char *)str_QString.local8Bit();
_pChar = (char *)std_string;

4、

a = str_QString.toint();
a = (int)_pChar;
a = atoi(str_string.c_str());

你可能感兴趣的:(QString、char*、std::string和int的转换)