This is not elegant, but it works ... So, the header class has Private:
QLabel *thisLabel; QString *pathName; QString *pathNameClean;
and, of course, defining this label somewhere. so it would be nice if it were that simple ....
thisLabel->setWordWrap(true);
that the penalty is IF and ONLY if the word has break points (WHICH WAY TO AVOID)
SO will save your actual path on a separate line if you need it later for QFile. Then manually define the character on the line number and insert spaces in the line .... so we say that 50 characters is a good width ...
pathNameClean = new QString(pathName); int c = pathName->length(); if( c > 50) { for(int i = 1; i <= c/50; i++) { int n = i * 50; pathName->insert(n, " "); } } thisLabel->setText(pathName);
Shazam .... imitated WordWrap without original spaces ...
just remember that the pathName line is now just for good QLabel purposes and that the pathNameClean line is the actual path. Qt programs will crash if you try to open the file using a space entered in the path .....
(if there is no simple class method, probably just a few lines of code ... and why problem solving is the best tool for programmers!)
budda
source share