Exemple #1
0
 def paint(self, painter, option, index):
     super().paint(painter, option, index)
     selected = option.state & QStyle.State_Selected
     if index.column() == 0:
         s_data = index.data(ValueRole)
         if s_data == 0:
             color = QColor(123, 123, 123)
         elif s_data == 1:
             color = QColor(224, 0, 0)
         elif s_data == 2:
             color = QColor(40, 140, 40)
         painter.save()
         painter.setRenderHint(QPainter.Antialiasing)
         pen = painter.pen()
         pen.setStyle(Qt.NoPen)
         painter.setPen(pen)
         painter.setBrush(color)
         rect_1 = QRect(option.rect)
         rect_1.adjust(2, 2, -3, -2)
         painter.drawRoundedRect(rect_1, 2, 2)
         painter.restore()
     if selected:
         gradient = QLinearGradient(0, 0, 66, 0)
         gradient.setColorAt(0, QColor(0, 0, 0, 255))
         gradient.setColorAt(1, QColor(0, 0, 0, 0))
         painter.setPen(QPen(gradient, 1))
         rect_2 = QRect(option.rect)
         painter.drawLine(rect_2.topLeft(), rect_2.topRight())
         painter.drawLine(rect_2.bottomLeft(), rect_2.bottomRight())
Exemple #2
0
 def paint(self, painter, option, index):
     super().paint(painter, option, index)
     selected = option.state & QStyle.State_Selected
     rect = QRect(option.rect)
     # painter.setRenderHint(QPainter.Antialiasing)
     if index.column() == 2 or index.column() == 3 or index.column() == 6:
         painter.setPen(QPen(QColor(255, 255, 255), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     elif index.column() == 4 or index.column() == 7:
         painter.setPen(QPen(QColor(0, 0, 0), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     elif index.column() == 5 or index.column() == 8:
         painter.setPen(QPen(QColor(0, 0, 0), 1))
         painter.drawLine(rect.topLeft(), rect.bottomLeft())
         painter.setPen(QPen(QColor(255, 255, 255), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     if selected:
         painter.setPen(QPen(QColor(255, 0, 0), 2))
         painter.drawLine(rect.topLeft(), rect.topRight())
         painter.drawLine(rect.bottomLeft(), rect.bottomRight())
Exemple #3
0
 def paint(self, painter, option, index):
     super().paint(painter, option, index)
     rect = QRect(option.rect)
     if not index.siblingAtColumn(0).data() == '-':
         painter.setPen(QPen(QColor(0, 0, 255), 2))
         painter.drawLine(rect.topLeft(), rect.topRight())
         painter.drawLine(rect.bottomLeft(), rect.bottomRight())
     selected = option.state & QStyle.State_Selected
     rect = QRect(option.rect)
     if index.column() == 6:
         painter.setPen(QPen(QColor(255, 255, 255), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     elif index.column() == 2 or index.column() == 4 or index.column() == 7:
         painter.setPen(QPen(QColor(0, 0, 0), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     elif index.column() == 3 or index.column() == 5 or index.column() == 8:
         painter.setPen(QPen(QColor(0, 0, 0), 1))
         painter.drawLine(rect.topLeft(), rect.bottomLeft())
         painter.setPen(QPen(QColor(255, 255, 255), 1))
         painter.drawLine(rect.topRight(), rect.bottomRight())
     if selected:
         painter.setPen(QPen(QColor(255, 0, 0), 2))
         painter.drawLine(rect.topLeft(), rect.topRight())
         painter.drawLine(rect.bottomLeft(), rect.bottomRight())