Results 1 to 2 of 2

Thread: How to display cutoff label with continuing dots?

  1. #1
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    7
    Qt products
    Qt4

    Default How to display cutoff label with continuing dots?

    I have a label that can't be bigger than fixed size. Therefore some strings are cutoff and some aren't. Is there a way to test if the text exceeds the size of the label? And then to draw "..." at the end of the string?

    Qt Code:
    1. QString numberStr = "1.234556776544";
    2. QLabel *label = new QLabel(numberStr);
    3. label->setToolTip(numberStr);
    4. label->setTextInteractionFlags(Qt::TextSelectableByMouse);
    5. label->setFixedWidth(66);
    6. l->addWidget(label);
    To copy to clipboard, switch view to plain text mode 
    Thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to display cutoff label with continuing dots?

    Try to use the QFontMetrics class.

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

    iwatsu (13th December 2011)

Similar Threads

  1. HOW TO DISPLAY A RECTANGLE ON AN IMAGE on a label
    By qt_user in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2010, 15:19
  2. Replies: 1
    Last Post: 23rd May 2009, 09:04
  3. display number on label
    By aj2903 in forum Qt Programming
    Replies: 4
    Last Post: 12th March 2009, 07:24
  4. how to display micro(mu) symbol in label
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 7th March 2008, 10:59
  5. Display a Label on top of a QGlWidget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2008, 16:11

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.