DrawText (single line) and EllipsisQt::TextSingleLine will keep the text in a single line, chopping it off if its dimensions exceed the given rect.
Is there an automated way to add an ellipsis (”…”) to the string and chop it such that the “…” is visible?
I know I could do it myself with some text dimension measuring that takes the current font and bounding rectangle into consideration. Is there built-in support for this in Qt? I couldn’t find any.
Take a look at the docs [doc.qt.nokia.com] for QString QFontMetrics::elidedText ( const QString & text, Qt::TextElideMode mode, int width, int flags = 0 ) const. That should do what you need. You can then paint the resulting string with QPainter as usual.