Sets the size of the string to size characters.
If size is greater than the current size, the string is extended to make it size characters long with the extra characters added to the end. The new characters are uninitialized.
If size is less than the current size, characters are removed from the end.
Example:
QString s = "Hello world";
s.resize(5);
// s == "Hello"
s.resize(8);
// s == "Hello???" (where ? stands for any character)
If you want to append a certain number of identical characters to the string, use operator+=() as follows rather than resize():
QString t = "Hello";
t += QString(10, 'X');
// t == "HelloXXXXXXXXXX"
If you want to expand the string so that it reaches a certain width and fill the new positions with a particular character, use the leftJustified() function:
If size is negative, it is equivalent to passing zero.
QString r = "Hello";
r = r.leftJustified(10, ' ');
// r == "Hello "