1. 去掉字符串多余的空格,回车等。
QString QString::simplified () const
Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.
Whitespace means any character for which QChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.
Example:
QString str = " lots\t of\nwhitespace\r\n ";
str = str.simplified();
// str == "lots of whitespace";
2.QString 子串分隔
QString test("one,two,three,four,five");
test=test.section(',',2,2); // "three"
test=test.section(',',-2,-2); //"four"
test=test.section(',',2); //"three,four,five"
QString test("oneistwoisthree");
test=test.section("is",1,1);//two