QT trimmed和simplified

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,开发语言)