QT -- QString handling

1. Remove extra spaces, carriage returns, etc. from the string.

QString 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.

Whitespace means any character for whichQChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '. 

Example:

     QString str = "  lots\t of\nwhitespace\r\n ";
     str = str.simplified();
     // str == "lots of whitespace";

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726301&siteId=291194637