Results 1 to 5 of 5

Thread: QPainter::drawText() with word wrap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QPainter::drawText() with word wrap

    Yeah, just tried and it worked. Thanks for your advice.

    Now I'm facing a bit minor problem. Text is wrapped as expected but returned size's height is much bigger than the text wrapped. See the attached view. Any ideas for that?

    sample2.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPainter::drawText() with word wrap

    The screenshot is extremely small, but I assume you mean that the item height is taller than what you expect.

    One thing you can try is to get the actually consumed bounding rect for the text drawing. The drawText() method has an option QRect pointer argument that, if present, will be set to the bounding rect the text actually needed when drawn.

    Qt Code:
    1. QRect usedRect;
    2. painter->drawText( itemRect, flags, text, &usedRect );
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

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

    zgulser (18th December 2013)

Similar Threads

  1. Replies: 2
    Last Post: 9th April 2013, 06:26
  2. word wrap
    By deeee in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2010, 19:55
  3. Long text and word wrap in QPainter
    By TomASS in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2009, 11:50
  4. KTitleWidget & word wrap
    By miraks in forum KDE Forum
    Replies: 3
    Last Post: 29th March 2009, 23:24
  5. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13

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
  •  
Qt is a trademark of The Qt Company.