QString str1="hello";
QString str2=str1+"to me"; //实现一个字符串末尾添加一个字符串 1
QString str3="its";
str3+=str1; //实现一个字符串末尾添加一个字符串 2
str1.append(str2); //实现一个字符串末尾添加一个字符串 3
str3.append(str1); //实现一个字符串末尾添加一个字符串 4
QString str;
str.sprintf("%s","welcome");
str.sprintf("%s","to me"); //和sprintf类似
str.sprintf("%s%s","welcome","to me");
qDebug()<<str;
QString sprint_str;
sprint_str=QString("%1 was born in %1=2").arg("WH").arg("HUNNAG");//和sprintf类似,但可以改变参数的顺序
qDebug()<<sprint_str;
bool temp;
QString strstr="hello to you";
temp=strstr.startsWith("hello",Qt::CaseSensitive);//判断一个字符串以某个字符串开头
qDebug()<<temp;
temp=strstr.endsWith("to",Qt::CaseSensitive);//判断一个字符串以某个字符串结尾
qDebug()<<temp;
temp=strstr.contains("to",Qt::CaseSensitive);//判断一个字符串是否出现过
qDebug()<<temp;
QString sntr="126";
int hex=sntr.toLong(&temp,16);
qDebug()<<temp<<hex;
int dex=sntr.toLong(&temp,10);//字符串的转换,将字符串转换成整型数值
qDebug()<<temp<<dex;