Results 1 to 2 of 2

Thread: Multi-line elided text?

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Multi-line elided text?

    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?

  2. #2
    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: Multi-line elided text?

    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...
    J-P Nurmi

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

    WinchellChung (6th February 2008)

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.