def drawBackground(self, painter, option, index): QItemDelegate.drawBackground(self,painter,option,index) item = index.model().itemFromIndex(index) print('----------- About to paint item with priority {0}'.format(item.task.priority)) item.setBackground(self.rowColors[item.task.priority]) painter.save() #painter.restore()
def paint(self, painter, option, index): painter.save() column = index.column() if column == 1: icon = index.model().data(index, Qt.DecorationRole) pixmap = icon.pixmap(option.rect.size() * 0.9) x = option.rect.left() + option.rect.width() / 2 - pixmap.width() / 2 rect = QRect(x, option.rect.top(), pixmap.width(), pixmap.height()) painter.drawPixmap(rect, pixmap) else: QItemDelegate.paint(self, painter, option, index) painter.restore()
def __init__(self, parent=None): QItemDelegate.__init__(self, parent)
def __init__(self, parent=None): QItemDelegate.__init__(self, parent) self._readonly = False
def updateEditorGeometry(self, QWidget, QStyleOptionViewItem, QModelIndex): QItemDelegate.updateEditorGeometry(self, QWidget, QStyleOptionViewItem, QModelIndex)