PDA

View Full Version : Multi-line elided text?



WinchellChung
6th February 2008, 16:39
I'm back with yet another of my unending stream of stupid newbie questions.

Now, if one wants elided text, it appears that one uses the QFontMetrics::elidedText() function. However, since it only accepts a "width" parameter, it appears that it only handles a single line of text.

But what if one was drawing a text string over several lines using the QPainter::drawText() function, where one is drawing inside a rectangle? Is there any way to elide multi-line text?

jpn
6th February 2008, 17:37
I did it once with help of QTextLayout (see "detailed description" for example code snippet). Unfortunately it was a commercial project so I have no example code to give. Just elide the last fitting line...