/* 表格视图样式 */ QTableView { border: none; /* 无外边框 */ alternate-background-color: transparent; /* 交替行背景颜色 */ gridline-color: transparent; /* 网格线颜色透明 */ } /* 表头样式 */ QHeaderView::section { background-color: #4472C4; font-weight: bold; color: white; height: 34px; /* 表头高度 */ resize-mode: Stretch; /* 表头自适应拉伸 */ } /* 交替行样式 */ QTableView::item:alternate { border: 0.5px solid transparent; /* 白色内边框 */ background-color: transparent; padding: 5px; /* 设置单元格内边距,增加行距 */ } /* 普通行样式 */ QTableView::item { border: 0.5px solid #BDC8E2; /* 白色内边框 */ background-color: #D9E1F2; padding: 5px; /* 设置单元格内边距,增加行距 */ } /* 垂直表头行高 */ QTableView QHeaderView::vertical::section { height: 28px; }