from PyQt4.QtCore import (QDate, QSize, QString, QVariant, Qt, SIGNAL)
from PyQt4.QtGui import (QApplication, QColor, QDateEdit, QLineEdit,
QSpinBox, QStyle, QStyledItemDelegate, QTextDocument)
import richtextlineedit
class GenericDelegate(QStyledItemDelegate):
def __init__(self, parent=None):
super(GenericDelegate, self).__init__(parent)
self.delegates = {
}
def insertColumnDelegate(self, column, delegate):
delegate.setParent(self)
self.delegates[column] = delegate
def removeColumnDelegate(self, column):
if column in self.delegates:
del self.delegates[column]
def paint(self, painter, option, index):
delegate = self.delegates.get(index.column())
if delegate is not None:
delegate.paint(painter, option, index)
else:
QStyledItemDelegate.paint(self, painter, option, index)
def createEditor(self, parent, option, index):
delegate = self.delegates.get(index.column())
if delegate is not None:
return delegate.createEditor(parent, option, index)
else:
return QStyledItemDelegate.createEditor(self, parent,
PyQt5代理
最新推荐文章于 2022-10-15 11:23:38 发布