How do I remove trailing whitespace from a QString?

前端 未结 9 1784
甜味超标
甜味超标 2020-12-29 19:24

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

9条回答
  •  暖寄归人
    2020-12-29 19:47

    If you don't have or don't need any whitespace at the beginning either, you could use QString QString::trimmed () const.

    This ignores any internal whitespace, which is corrected by the alternative solution provided by Andrejs Cainikovs.

提交回复
热议问题