Here we will introduce the two functions in QString.
1. QString: simplified () const
Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.
Returns a string to remove the spaces from the beginning to the end. Replace the spaces in each sequence with a space (the first and last spaces are removed)
For example: [cpp]
<SPAN style = "FONT-SIZE: 18px"> QString str = "lots \ t of \ nwhitespace \ r \ n ";
Str = str. simplified ();
// Str = "lots of whitespace"; </SPAN>
QString str = "lots \ t of \ nwhitespace \ r \ n ";
Str = str. simplified ();
// Str = "lots of whitespace"; '\ t',' \ n', '\ V',' \ F', '\ R ', ''all belong to the blank processing range.
2. QString: trimmed () const
Returns a string that has whitespace removed from the start and the end.
Returns a string that removes spaces from the beginning to the end. Also remove the leading and trailing Spaces
For example:
[Cpp]
<SPAN style = "FONT-SIZE: 18px"> QString str = "lots \ t of \ nwhitespace \ r \ n ";
Str = str. trimmed ();
// Str = "lots \ t of \ nwhitespace" </SPAN>
QString str = "lots \ t of \ nwhitespace \ r \ n ";
Str = str. trimmed ();
// Str = "lots \ t of \ nwhitespace"