分割字符串
QByteArray x("FIVE pineapples");
QString y = x.mid(5,4); //y == "pine"
QString z = x.mid(5); //z == "pineapples";
字符串查找
QString x = "sticky question";
QString y = "sti";x.indexOf(y); returns 0
x.indexOf(y, 1); returns 10
x.indexOf(y, 10); returns 10
x.indexOf(y, 11); returns -1
字符串与字符串开头匹配
QString str = "Bananas";str.startsWith("Ban"); returns true
str.startsWith("Car"); returns false
字符串与字符串结尾匹配
QString str = "Bananas";str.endsWith("anas"); returns true
str.endsWith("pple"); returns false
按字符分割字符串
QString str = "a,,b,c";
QStringList list1 = str.split(",");
list1: [ "a", "", "b", "c" ]
QStringList list2 = str.split(",", QString::SkipEmptyParts);
list2: [ "a", "b", "c"]