Signature : QString wordWrap(const QString &str, int wrapLength)
Argument : 1. The QString to be wrapped
2. The permissible number of characters per line.
Return Value: The wrapped QString
QString wordWrap(const QString &str, int wrapLength)
{
QString tempStr= str;
int len = str.length(), pos= (wrapLength>1)?wrapLength -1:1;
while(pos < len-1){
int tempPos=pos;
while(tempStr.at(tempPos)!=' ' && tempPos > 0){
tempPos--;
}
if(tempPos > 0)pos=tempPos;
tempStr.replace(pos,1,'\n');
pos+=pos;
}
return tempStr;
