PDA

View Full Version : QTableWidget stretch a column other than the last one



roleroz
24th August 2006, 20:00
I have a QTableWidget, and want the last row to be resized just if i manually do, but the first column to be the one stretching to get the full width. To have the last column stretching you can use a QTableHeaderView, but don't know how to do it for another column

Any ideas?

Best Regards

jacek
24th August 2006, 20:11
QHeaderView::setResizeMode()

roleroz
24th August 2006, 20:29
Tried this, didn't work



colorizerTable = new QTableWidget(0, 3, colorizerWidget);
colorizerTable->setSortingEnabled(false);
QHeaderView *headerView = new QHeaderView(Qt::Horizontal, colorizerTable);
headerView->setResizeMode(0, QHeaderView::Stretch);
headerView->setResizeMode(1, QHeaderView::Interactive);
colorizerTable->setHorizontalHeader(headerView);
colorizerTable->hideColumn(2);


Do you know what i'm doing wrong?

roleroz
24th August 2006, 20:35
Fixed



colorizerTable = new QTableWidget(0, 3, colorizerWidget);
colorizerTable->setSortingEnabled(false);
QHeaderView *headerView = new QHeaderView(Qt::Horizontal, colorizerTable);
colorizerTable->setHorizontalHeader(headerView);
headerView->setResizeMode(0, QHeaderView::Stretch);
headerView->setResizeMode(1, QHeaderView::Interactive);
headerView->resizeSection(1, 40);
headerView->hideSection(2);


Just needed to set the headerView to the table before setting the headerView parameters

jpn
24th August 2006, 20:36
Does it work this way?


QHeaderView *headerView = colorizerTable->horizontalHeader();
headerView->setResizeMode(QHeaderView::Stretch);
headerView->setResizeMode(1, QHeaderView::Interactive);

roleroz
24th August 2006, 20:41
Yes, it does :D :D

Thanks

ShapeShiftme
4th February 2015, 07:35
Fo qt5 use setSectionResizeMode and not setResizeMode.

Have an awesome day.