本文整理汇总了Python中spyderlib.qt.QtGui.QItemDelegate类的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate类的具体用法?Python QItemDelegate怎么用?Python QItemDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QItemDelegate类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setEditorData
def setEditorData(self, editor, index):
text = from_qvariant(index.model().data(index, Qt.DisplayRole), str)
if index.column() in (MOD1, MOD2, MOD3, KEY):
i = editor.findText(text)
if i == -1:
i = 0
editor.setCurrentIndex(i)
else:
QItemDelegate.setEditorData(self, editor, index)
示例2: sizeHint
def sizeHint(self, option, index):
fm = option.fontMetrics
if index.column() in (MOD1, MOD2, MOD3):
if self.mod is None:
w = 0
for mod in self.modifiers:
cw = fm.width(mod)
if cw > w:
w = cw
self.mod = mod
else:
w = fm.width(self.mod)
return QSize(w+20, fm.height())
elif index.column() == KEY:
if self.key is None:
w = 0
for key in self.keys:
cw = fm.width(key)
if cw > w:
w = cw
self.key = key
else:
w = fm.width(self.key)
return QSize(w+20, fm.height())
return QItemDelegate.sizeHint(self, option, index)
示例3: createEditor
def createEditor(self, parent, option, index):
if index.column() in (MOD1, MOD2, MOD3):
combobox = QComboBox(parent)
combobox.addItems(self.modifiers)
return combobox
elif index.column() == KEY:
combobox = QComboBox(parent)
combobox.addItems(self.keys)
return combobox
else:
return QItemDelegate.createEditor(self, parent, option, index)
示例4: __init__
def __init__(self, dtype, parent=None):
QItemDelegate.__init__(self, parent)
self.dtype = dtype
示例5: __init__
def __init__(self, parent=None):
QItemDelegate.__init__(self, parent)
示例6: setModelData
def setModelData(self, editor, model, index):
if index.column() in (MOD1, MOD2, MOD3, KEY):
model.setData(index, to_qvariant(editor.currentText()))
else:
QItemDelegate.setModelData(self, editor, model, index)
示例7: __init__
def __init__(self, parent=None):
QItemDelegate.__init__(self, parent)
self.modifiers = sorted(Key.MODIFIERNAMES.values())
self.mod = None
self.keys = sorted(Key.KEYS.values())
self.key = None