QTableView row height
-
I want to shrink the row height for all rows in the table view as there's more vertical white space around the contents than I would like:
something more like this is what I'm after:
I rapidly found setRowHeight() but that just sets it for ONE row, not all rows.
How should I do this please?
Thanks, David -
I want to shrink the row height for all rows in the table view as there's more vertical white space around the contents than I would like:
something more like this is what I'm after:
I rapidly found setRowHeight() but that just sets it for ONE row, not all rows.
How should I do this please?
Thanks, David@Perdrix , @hskoglund
To do this fixed for all rows --- so that e.g. it also applies whenever a new row is inserted --- you do it onQTableView->verticalHeader()
. See https://stackoverflow.com/a/19304739 for example/discussion. -
Every tableview has a vertical and a horizontal header.
-
So is this right?
// // Reduce the row height somewhat // QHeaderView* verticalHeader = pictureList->tableView->verticalHeader(); double height = verticalHeader->defaultSectionSize(); height *= 0.8; //verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(height);
or do also need the setSectionResizeMode?
-
So is this right?
// // Reduce the row height somewhat // QHeaderView* verticalHeader = pictureList->tableView->verticalHeader(); double height = verticalHeader->defaultSectionSize(); height *= 0.8; //verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(height);
or do also need the setSectionResizeMode?
@Perdrix said in QTableView row height:
How do I find the default row height before any rows have been added?
Reading a documentation seems to be really hard for a lot of people... https://doc.qt.io/qt-6/qheaderview.html#defaultSectionSize-prop
-
So is this right?
// // Reduce the row height somewhat // QHeaderView* verticalHeader = pictureList->tableView->verticalHeader(); double height = verticalHeader->defaultSectionSize(); height *= 0.8; //verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(height);
or do also need the setSectionResizeMode?
-
It's more a case of understanding WHERE you need to look - once you have the CORRECT part of the docs located, it's fine. Sometimes it's not always obvious.
PS I changed my post so it's now asking a different Q (that change crossed with your post).
D.