class MyItemDelegate(QtGui.QItemDelegate):

    def __init__(self, parent=None):
        super(MyItemDelegate, self).__init__(parent)

def paint(self, painter, option, index):
    text = index.model().data(index, QtCore.Qt.DisplayRole).toString()
pushButton = QtGui.QPushButton()
pushButton.setText(text)
pushButton.setGeometry(option.rect)
painter.save()
painter.translate(option.rect.x(), option.rect.y())
pushButton.render(painter)
painter.restore()
Smooth lazy loading and unloading of custom IndexWidget in QListView