Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set row height of QTableView?

I have QTableView and QAbstractTableModel. I require rows to have height equal to 24. I know the only way to do this is by calling QTableView::setRowHeight. Since the model is dynamic it may be added new rows, but I don't want to call setRowHeight each time new row is added.

How can I configure QTableView such that it uses the same height for new added rows or can a model be sent the height of rows?

like image 461
Ashot Avatar asked Oct 10 '13 19:10

Ashot


1 Answers

For Qt versions < 5

QHeaderView *verticalHeader = myTableView->verticalHeader(); verticalHeader->setResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(24); 

For Qt versions >= 5 use

QHeaderView *verticalHeader = myTableView->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(24); 

If that function doesn't apply to vertical headers, you likely will have to call setRowHeight() every time you add a new row.

like image 106
Cory Klein Avatar answered Sep 20 '22 20:09

Cory Klein