空白
分类: C/C++
2013-03-31 21:58:54
<1> char * 与 const char *的转换
char *ch1 = "ABCD";
const char *ch2;
ch1 = (char *)ch2;
<2>char 转换为 QString
char ch = 'A';
QString str;
str = QString(ch);
<3> QString 转换为 char *
QString str="ABC";
char *ch;
ch = str.toLatin1.data();
<4> QByteArray 转换为 char *
char *ch;
QByteArray byte;
ch = byte.data();
<5> char *转换为 QByteArray
char *ch;
QByteArray byte;
byte = QByteArray(ch);
<6> QString 转换为 QByteArray
QByteArray byte;
QString str;
byte = str.toAscii();
<7> QByteArray 转换为 QString
QByteArray byte;
QString string;
string = QString(byte)
<8> int 转 QString
int a = 10;
QString str;
str = QString::number(a);
<9> QString 转 int
QString str="100";
int b;
b = str.toInt();