Results 1 to 7 of 7

Thread: QLabel Word Wrapping adds unnecessary line breaks

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2014
    Posts
    27
    Thanks
    2
    Thanked 2 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel Word Wrapping adds unnecessary line breaks

    Quote Originally Posted by wysota View Post
    I would suspect some kind of rounding error or a similar off-by-one behavior.
    Do you have any idea if there is some method I could reimplement in my QLabel subclass to control this behavior? I just really don't like the look of those unnecessary line breaks. I suppose I could just set my own line breaks based on the length of the string, which I assume is what QLabel does anyway, but I would have the advantage of programming for my one specific instance where I don't even need the labels to resize after they have been created.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLabel Word Wrapping adds unnecessary line breaks

    Quote Originally Posted by forgottenduck View Post
    Do you have any idea if there is some method I could reimplement in my QLabel subclass to control this behavior?
    sizeHint(), I guess.

    I suppose I could just set my own line breaks based on the length of the string, which I assume is what QLabel does anyway,
    No, it doesn't You can use QTextLayout if you want to layout the text yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    forgottenduck (2nd April 2015)

  4. #3
    Join Date
    Sep 2014
    Posts
    27
    Thanks
    2
    Thanked 2 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel Word Wrapping adds unnecessary line breaks

    Quote Originally Posted by wysota View Post
    You can use QTextLayout if you want to layout the text yourself.
    Ah this looks like it might offer what I need. I'll probably have to bookmark it and get back to the issue when I have more time, but it's good to know about. Thanks!

Similar Threads

  1. QTextTable and word wrapping
    By ssample in forum Qt Programming
    Replies: 0
    Last Post: 21st May 2013, 09:38
  2. qtexttable - word wrapping
    By ssample in forum General Programming
    Replies: 0
    Last Post: 19th May 2013, 08:55
  3. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57
  4. Word wrapping
    By bruccutler in forum Qt Programming
    Replies: 4
    Last Post: 26th February 2007, 16:33
  5. word wrapping in QTable Cell
    By joseph in forum General Discussion
    Replies: 0
    Last Post: 27th November 2006, 09:30

Tags for this Thread

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.