1、替换QString中字符串
QString text("text-decoration: none");
text.replace("none", "underline");
2、去除QString首尾的空格(包括'\t', '\n', '\v', '\f', '\r')
QString text(" text-decoration: none ");
text = text.trimmed();
3、字符移除操作
QString test = "hello,china";
QString tmp = test.remove(2, 4); //从下标2的字符开始, 移除4个字符
qDebug() << "test = " << test; //输出hechina
qDebug() << "tmp = " << tmp; //输出hechina
4、判断字符是否以某字符或字符串开始
QString test= "@192.168.0.1";
if(true == test.startsWith("@")) { }
QString字符替换
最新推荐文章于 2024-05-09 17:22:31 发布