PDA

View Full Version : QTableWidget, WordWrap not working with ResizeToContents



Yoshop
7th September 2017, 16:45
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 :

12576

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 :

ui.tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents );
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 :

12577

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

high_flyer
7th September 2017, 16:52
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?

Yoshop
7th September 2017, 21:07
Yes. And I don't see why.

Santosh Reddy
8th September 2017, 08:16
Works just fine on macOS Qt 5.9.0.

Yoshop
8th September 2017, 14:08
I just tried on v5.9.1 (windows) and I have the same issue.