QString QString::leftJustified ( int width, QChar fill = QLatin1Char( ' ' ), bool truncate = false ) const
Returns a string of size width that contains this string padded by the fill character.
If truncate is false and the size() of the string is more than width, then the returned string is a copy of the string.
eg.
QString s = "apple";
QString t = s.leftJustified(8, '.'); // t == "apple..."
If truncate is true and the size() of the string is more than width, then any characters in a copy of the string after position width are removed, and the copy is returned.
eg.
QString str = "Pineapple";
str = str.leftJustified(5, '.', true); // str == "Pinea"
这个是qt assistant里面的,只是一个思路 ,里面可能有更好的方法
[ 此帖被83888788在2011-04-05 01:21重新编辑 ]