PDA

View Full Version : row height in QTreeView and QTableView



yuriry
9th October 2008, 01:12
I'm using standard QTreeView and QTableView. I'd like the row height in both view types to be the same, but default heights are different and QTableView's row height is significantly larger than QTreeView's row height. What would be the correct way to make the heights the same?

P.S. I use the same item delegate, sub-classed from QItemDelegate, in both view types. I tried to override QItemDelegate::sizeHint() and what I see is QItemDelegate::sizeHint() is called by QTreeView but is not called by QTableView. Could this be related to my row height problem?

yuriry
9th October 2008, 01:47
Update: I was able to explicitly reduce the row height by using tableView->verticalHeader()->setDefaultSectionSize() but am not sure if this is the right thing to do. I'd like to have a mechanism that only depends on the data that the table view displays. I just need to reduce vertical margins around the data cells. Would this be possible?

yuriry
9th October 2008, 01:58
Sorry for the spam: it looks like QHeaderView::setResizeMode(QHeaderView::ResizeToCo ntents) solved my problem.