Having different header width while using QHeaderView::Stretch
Solved
General and Desktop
-
Hi. I have an application where to the far left is a checkbox and the rest of the table contains text. Like so.
Another example:
I want to resize the far left to something much more narrow, but have the remaining headers retain their ability to stretch, like so.
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->tableWidget->setColumnWidth(0, 30);
According to the documentation on QHeaderView::Stretch, "The size cannot be changed by the user or programmatically." This is why I'm wondering whether there exists a way to retain the header view stretch size.
-
There is another overload of setSectionResizeMode that takes a section index. Use it to set section 0 mode to
QHeaderView::Fixed
and give it a fixed size with resizeSecion.