QHeaderView: Stretch *and* ResizeToContents?
Solved
General and Desktop
-
Hi all -
This probably sounds weird, but I'm trying to format a QTableView so that each column's content is fully visible.
When I use ResizeToContents mode, it looks like this:
and when I use Stretch, it looks like this:
I could use minimum column widths, I suppose, but...is there a better way to to it?
Thanks...
-
Can you show what exactly you're doing (code)?
I usually use:view->horizontalHeader()->setSectionResizeMode(...);
To tweak the appearance of the sections, but it's hard to tell if that's what you're looking for exactly.
-
QSizePolicy qsp; QHeaderView *qhv; // set the size policy to expanding. qsp.setHorizontalPolicy(QSizePolicy::Expanding); qsp.setVerticalPolicy(QSizePolicy::Expanding); // set the table to stretch mode. qhv = ui->tableView->horizontalHeader(); qhv->setSectionResizeMode(QHeaderView::Stretch);