QString 字符串操作
QString str1 = "Welcom";
str1 = str1+" to New York!";
//str1 = "Welcom to New York!"
QString str2 = "Welcom";
str2 +=" to New York!";
//str2 = "Welcom to New York!"
QString str3 = "Welcom";
QString str4 = "to";
str3.append(str4);
str3.append(" New York!");
//str3 = "Welcom to New York!"
QString str5;
str5.sprintf("%s %s","Welcom to","New York!")
//str5 = "Welcom to New York!"
QString str6;
str6 = QString("%1 to %2!").arg("Welcom").arg("New York");
//str6 = "Welcom to New York!"
特定操作
QString::insert();//指定位置插入字符串
QString::prepend();//开头位置插入字符串
QString::replace();//用指定字符串 替换某字符串
QString::trimmed();//移除字符串两端空白
QString::simplified();//移除字符串两端空白,使用单个空格代替字符中出现的空白字符
查询字符串数据
QString::statrsWith();//是否以某个字符串开头
QString::contains();//是否包含某个字符串
QString::endsWith();//是否已某个字符串结束
比较字符串
operator<(const QString&) //是否小于 返回bool类型
operator<=(const QString&) //是否小于等于 返回bool类型
operator==(const QString&) //是否相等 返回bool类型
operator>=(const QString&) //是否大于等于 返回bool类型
字符串转换、判断
QString::toInt();
QString::toDouble();
QString::toFloat();
QString::toLong();
QString::toLongLong();
QString::isNull();//判断是否为NULL字符串
QString::toEmpty();//判断是否为空字符串