def headerData(self, section: int, orientation, role=Qt.DisplayRole):
if orientation == Qt.Vertical:
if role == Qt.DisplayRole:
return self.vertical_header_text[section]
elif role == Qt.BackgroundColorRole:
return self.vertical_header_colors[section]
elif role == Qt.TextColorRole:
color = self.vertical_header_colors[section]
if color:
red, green, blue = color.red(), color.green(), color.blue()
return QColor("black") if (red * 0.299 + green * 0.587 + blue * 0.114) > 186 else QColor("white")
else:
return None
return super().headerData(section, orientation, role)
评论列表
文章目录