QString
has two methods related to trimming whitespace:
If you want to remove only trailing whitespace, you need to implement that yourself. Here is such an implementation which mimics the implementation of trimmed
:
QString rstrip(const QString& str) {
int n = str.size() - 1;
for (; n >= 0; --n) {
if (!str.at(n).isSpace()) {
return str.left(n + 1);
}
}
return "";
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…