PDA

View Full Version : How to trim long text in status bar



araglin
13th January 2009, 20:21
Hello!
Would you please tell me the efficient way to trim long text in status bar if window becomes rather small. Trim and add "..." at the end of trimmed text.

For example, I have a string like "longlonglongtext".
If main window of the application is maximized it's ok, but when user sized the window down need to have something like "longlonglo...".

By default, as I could see, the text is trimmed, but it would be nice to add these three dots at the end....

If the only way is to change the text manually how to find out how many characters to trim if the width of the window (in pixels) is known?

THRESHE
15th January 2009, 20:10
You can add QLabel to your status bar with QStatusBar::addWidget and then tell QLabel to wrap long text with QLabel::setWordWrap :)

jpn
15th January 2009, 21:36
You could use QxtLabel (http://doc.libqxt.org/latest/classQxtLabel.html). :)