trimmed:去除了字符串开头前和结尾后的空白;

simplified:去除了字符串开头前和结尾后的空白,以及中间内部的空白字符也去掉(\t','\n','\v','\f','\r'和' ')

代码:

QString str = "     1 2 3 4 5    \t  \n    ABCDE   ";
str = str.trimmed();
qDebug() << "start:" << str << ":end";

str = str.simplified();
qDebug() << "start:" << str << ":end";

结果:

QT trimmed和simplified-LMLPHP

12-26 01:35