本文整理匯總了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