2012年(29)
分类: C/C++
2012-06-15 10:07:40
char * 与 const char *的转换
char *ch1="hello11";
const char *ch2="hello22";
ch2 = ch1;//不报错,但有警告
ch1 = (char *)ch2;
char 转换为 QString
char a='b';
QString str;
str=QString(a);
QString 转换为 char
QString str="abc";
char *ch;
ch = str.toLatin1.data();
QByteArray 转换为 char *
char *ch;//不要定义成ch[n];
QByteArray byte;
ch = byte.data();
char * 转换为 QByteArray
char *ch;
QByteArray byte;
byte = QByteArray(ch);
QString 转换为 QByteArray
QByteArray byte;
QString string;
byte = string.toAscii();
QByteArray 转换为 QString
QByteArray byte;
QString string;
string = QString(byte);
int 转 QString
int a=10;
QString b;
b=QString::number(a)
QString 转int
QString a="120"
int b;
b=a.toInt()