class ImageDelegate(QtGui.QStyledItemDelegate):
def __init__(self, parent):
QtGui.QStyledItemDelegate.__init__(self, parent)
def paint(self, painter, option, index):
painter.
fillRect(option.
rect, QtGui.
QColor(191,
222,
185))
path = "image.jpg"
image
= QtGui.
QImage(str
(path
)) pixmap
= QtGui.
QPixmap.
fromImage(image
) pixmap.scaled(50, 40, QtCore.Qt.KeepAspectRatio)
painter.drawPixmap(option.rect, pixmap)
class ImageDelegate(QtGui.QStyledItemDelegate):
def __init__(self, parent):
QtGui.QStyledItemDelegate.__init__(self, parent)
def paint(self, painter, option, index):
painter.fillRect(option.rect, QtGui.QColor(191,222,185))
path = "image.jpg"
image = QtGui.QImage(str(path))
pixmap = QtGui.QPixmap.fromImage(image)
pixmap.scaled(50, 40, QtCore.Qt.KeepAspectRatio)
painter.drawPixmap(option.rect, pixmap)
To copy to clipboard, switch view to plain text mode
Bookmarks