PDA

View Full Version : Help with QTableWidget



aarelovich
17th July 2009, 22:02
Hi:
I've got a very simple problem: I have a table (QTableWidget) with the number of columns that changes. I would like to make it so that the columns allways fill the entire QTableWidget area. I can do this by taking the width of the QTableWidget object and dividing it by the number of columns and setting each of the columns to that width and do this with every resize. But it's results aren't really perfect because of the rounding involved. I thought may there was anoter way to do this?
Thanks.

wysota
17th July 2009, 22:47
See QHeaderView::setResizeMode() with QHeaderView::Stretch.

aarelovich
18th July 2009, 15:04
HI:

I've tried to do what you told me in two different ways and both do nothing.

Here is the code for way 1:


ui->twResults->verticalHeader()->setResizeMode(QHeaderView::Stretch);


And for way 2:


QHeaderView *view;
view = ui->twBoard->verticalHeader();
view->setResizeMode(QHeaderView::Stretch);
ui->twBoard->setVerticalHeader(view);


twBoard and twResults are the two widgets that need the formatting.
Am I doing something wrong?

wysota
19th July 2009, 21:11
You should use the horizontal header.

aarelovich
20th July 2009, 12:22
That worked. And now that I think about it, I realized my mistake. I always confuse the vertical and horizontal headers because i think of the cell orientations....

Well thank you very much.