Project

General

Profile

Does WLength::Percentage actually work?

Added by Vincenzo Romano almost 11 years ago

I need to size the column widths in a WTableView so that the content of the columns is displayed in a (more or less) optimal way.

I know the maximum length in characters of each column so some simple math should help.

But this seems no to be the case.

My screen layout has a right side eating 90% of the screen real estate (horizontal stretch factor of 9) and a few widgets vertically stacked on the left eating the remaining 10% (horizontal stretch factor of 1).

The WTableView is sitting in that large are on the right.

If I let the library use the automatic (150px) column width, everything goes fine, despite not being my target.

If I compute the column widths as percentage in order to call setColumnWidth( i,WLength( wl,WLength::Percentage ) ) , the result is really weird.

Not only the specified column widths are not honored, but even the "external" widget layout is stretched. See screen shots.

Thus my question in the title.

Or am I missing some important bit here?

shot-0252.png (57.4 KB) shot-0252.png Automatic (150px) column widths
shot-0251.png (30.3 KB) shot-0251.png Percentage column widths

Replies (2)

RE: Does WLength::Percentage actually work? - Added by Wim Dumon almost 11 years ago

Hi,

WLength::Percentage is mapped to CSS's percentage attribute. The width of columns of a WTableView cannot be set as percentage.

Br,

Wim.

RE: Does WLength::Percentage actually work? - Added by Simon M about 7 years ago

Just ran into this issue as well.

Is there any suggestion how to set table columns in percentage?

    (1-2/2)