[Qt-interest] QTableWidget and QHeaderView::ResizeToContents don't work

Malyushytsky, Alex alex at wai.com
Sat Nov 21 02:57:33 CET 2009


I am trying to  make QTableWidget to automatically resize the section to the maximum size of the data in the column.

For each column I set resize mode (ResizeToContents) when I initialize the table.
table->horizontalHeader()->setResizeMode(col, QHeaderView::ResizeToContents);

It does automatically chose width of the column to be fully visible, but only at the time of the setResizeMode.
When width of the data (text in my case) set to the cell after such call is larger than column width, part it remains invisible.
This happens at least in the case when all columns don't fit viewport).

User then has no way to make it visible. The only way I found to fix it - is to resize table widget so it size become wider than column width. In this case column will be resized to fit text.

Programmatically I can change ResizeMode twice to fix the problem after I fill the table with data:

        this->horizontalHeader()->setResizeMode( col, QHeaderView::Fixed);
        this->horizontalHeader()->setResizeMode( col, QHeaderView::ResizeToContents);


But this kills the purpose and sounds like a bug to me.
QT 4.4.3 , Windows, MVC 2005.

Anybody can confirm such behavior before I report the bug?

Alex Malyushytsky
Research Engineer - Weidlinger Associates Inc.
office: 650 230 0210,
direct: 650 230 0349
web: http://www.wai.com


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list