How to set row height of QTableView?

前端 未结 1 1333
眼角桃花
眼角桃花 2021-01-31 08:21

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::se

相关标签:
1条回答
  • 2021-01-31 08:49

    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.

    0 讨论(0)
提交回复
热议问题