Results 1 to 5 of 5

Thread: QTableWidget, WordWrap not working with ResizeToContents

  1. #1
    Join Date
    Sep 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Question QTableWidget, WordWrap not working with ResizeToContents

    Hello,

    I'm using a QTableWidget with 3 columns, and I want the last one to be vertically resized to display all the content with wordWraping.

    It's working, but sometimes, depending on the content and the table width (the window can be resized), the word wrap fails !!!

    Here an example where it failed :

    tableWidget.png

    The text shall end with "[...] AAA BBB CCC", but it's truncated.


    - The last column is using all available space, with the property "horizontalHeaderStretchLastSection"
    - ElideMode is set to None because I don't want Ellipsis, I want to see all the text
    - To have multilines, I set wordWrap Enabled and configure vertical Header to be resized to the content :
    Qt Code:
    1. ui.tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    To copy to clipboard, switch view to plain text mode 
    I also tried to manually call resizeRowsToContents() but the result is the same

    (I'm using Qt5.4.2)

    I made a simple example, you can resize the window to illustrate the issue :

    TableWidget.zip

    Am I doing something wrong ? Do you have any clues ?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget, WordWrap not working with ResizeToContents

    It's working, but sometimes, depending on the content and the table width (the window can be resized), the word wrap fails !!!
    Do you mean that sometimes the word-wrap works, and sometimes it does not work?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTableWidget, WordWrap not working with ResizeToContents

    Yes. And I don't see why.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTableWidget, WordWrap not working with ResizeToContents

    Works just fine on macOS Qt 5.9.0.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Sep 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTableWidget, WordWrap not working with ResizeToContents

    I just tried on v5.9.1 (windows) and I have the same issue.

Similar Threads

  1. Replies: 15
    Last Post: 13th September 2015, 20:07
  2. QTableWidget cellwidgets ResizeToContents
    By Henry Blue Heeler in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2015, 00:10
  3. QPushbotton - WordWrap
    By anju123 in forum Qt Programming
    Replies: 15
    Last Post: 24th January 2012, 21:41
  4. wordwrap question -2
    By igor_x in forum Newbie
    Replies: 0
    Last Post: 3rd November 2006, 06:11
  5. wordwrap question
    By igor_x in forum Newbie
    Replies: 2
    Last Post: 2nd November 2006, 11:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.