(view: QTableView)
Give the view a more compact default vertical header section size.
Give the view a more compact default vertical header section size.
Give the view a more compact default vertical header section size .
def table_view_compact(view: QTableView) -> None:
    """
    Give the view a more compact default vertical header section size.
    """
    vheader = view.verticalHeader()
    option = view.viewOptions()
    option.text = "X"
    option.features |= QStyleOptionViewItem.HasDisplay
    size = view.style().sizeFromContents(
        QStyle.CT_ItemViewItem, option,
        QSize(20, 20), view
    )
    vheader.ensurePolished()
    vheader.setDefaultSectionSize(
        max(size.height(), vheader.minimumSectionSize())
    )
def table_view_compact ( view : QTableView ) -> None : vheader = view . verticalHeader ( ) option = view . viewOptions ( ) option . text = "X" option . features |= QStyleOptionViewItem . HasDisplay size = view . style ( ) . sizeFromContents ( QStyle . CT_ItemViewItem , option , QSize ( 20 , 20 ) , view ) vheader . ensurePolished ( ) vheader . setDefaultSectionSize ( max ( size . height ( ) , vheader . minimumSectionSize ( ) ) )