2024-04-23 19:37:53 发布
网友
好的,我们可以为包含数据的单元格设置特定的背景色:
self.Table.item(0,i).setBackground(QColor(255,128,128))
是否可以在启动或操作期间将整个表设置为特定颜色?启动时,它不包含任何数据,因此单元格为空
如果希望所有单元格都具有该背景色,则可以使用代理:
class Delegate(QStyledItemDelegate): def initStyleOption(self, option, index): super().initStyleOption(option, index) if not index.data(Qt.BackgroundRole): option.backgroundBrush = QBrush(QColor(255, 128, 128))
delegate = Delegate(self.Table) self.Table.setItemDelegate(delegate)
如果希望所有单元格都具有该背景色,则可以使用代理:
相关问题 更多 >
编程相关推荐