I want to remove all the trailing whitespace characters in a QString. I am looking to do what the Python function str.rstrip() with a QString
QString
str.rstrip()
No deep copy and no repeated calls to size/chop:
QString & rtrimInPlace (QString &str) { for (int n = str.size() - 1; n >= 0; -- n) if (!str.at(n).isSpace()) { str.truncate(n + 1); break; } return str; }