Results 1 to 3 of 3

Thread: How to trim long text in status bar

  1. #1
    Join Date
    Dec 2008
    Posts
    32
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to trim long text in status bar

    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?

  2. #2
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to trim long text in status bar

    You can add QLabel to your status bar with QStatusBar::addWidget and then tell QLabel to wrap long text with QLabel::setWordWrap
    C++ & AMD forever

  3. The following user says thank you to THRESHE for this useful post:

    araglin (20th January 2009)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to trim long text in status bar

    You could use QxtLabel.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    araglin (20th January 2009)

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. how to srcoll a long text in one line from right to left?
    By deweyjew in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2006, 10:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.