Qt中QString的类型转换

(1)int 转QString
int a = 10;
QString b;
b = QString::number(a);

QString转int
QString a = "120";
int b;
b = a.tolnt();
(2)char * 转化为QString
char *p = "abc";
QString str;
str = QString(QLatin1String(p)) ;

QString 转char *
QString str = "qwe";
char *ch;
ch = str.toLatin1.data();
(3)char转QString
char a  = 'b';
QString str;
str = QString(a);

QString转char
QString str = "abc";
char *ch;
ch = str.toLatin1.data();

你可能感兴趣的:(Qt)