本文整理汇总了Python中PyQt4.QtGui.QItemDelegate.setEditorData方法的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate.setEditorData方法的具体用法?Python QItemDelegate.setEditorData怎么用?Python QItemDelegate.setEditorData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemDelegate
的用法示例。
在下文中一共展示了QItemDelegate.setEditorData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
""" load data from model to editor """
m = index.model()
if index.column() == 1:
txt = m.data(index, Qt.DisplayRole)
editor.setEditText(txt)
else:
# use default
QItemDelegate.setEditorData(self, editor, index)
示例2: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
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)
示例3: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self,editor,index):
"""Set initial data for the editor"""
if index.column() == 0:
current = index.model().data(index,Qt.DisplayRole)
editor.setText(current)
elif index.column() == 1:
current = index.model().data(index,Qt.DisplayRole)
editor.setCurrentIndex(editor.findData(current))
else:
QItemDelegate.setEditorData(self,editor,index)
示例4: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
model = index.model()
horse = model.horseList[index.row()]
if model.isColumn("name", index):
editor.setText(horse.name)
elif model.isColumn("rating", index):
ratingIndex = model.getColumn("rating", index)
editor.setValue(horse[ratingIndex])
elif model.isColumn("adjust", index):
adjustIndex = model.getColumn("adjust", index)
editor.setValue(model.race.adjusts.getAdjust(model.race.adjusts[adjustIndex], horse))
else:
QItemDelegate.setEditorData(self, editor, index)
示例5: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
""" load data from model to editor """
m = index.model()
try:
if index.column() == self.column:
txt = m.data(index, Qt.DisplayRole)
checkList = txt[1:-1].split(',')
for i in range(editor.count()):
item = editor.item(i)
item.setCheckState(Qt.Checked if item.text() in checkList else Qt.Unchecked)
else:
# use default
QItemDelegate.setEditorData(self, editor, index)
except:
pass
示例6: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
if isinstance(editor, QComboBox):
i = editor.findText(index.data(Qt.EditRole).toString())
if i > -1:
editor.setCurrentIndex(i)
else:
editor.setEditText(index.data(Qt.EditRole).toString())
editor.lineEdit().selectAll()
elif isinstance(editor, QTextEdit):
editor.setText(index.data(Qt.EditRole).toString())
editor.selectAll()
else:
return QItemDelegate.setEditorData(self, editor, index)
示例7: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, QWidget, QModelIndex):
QItemDelegate.setEditorData(self, QWidget, QModelIndex)
示例8: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
if isinstance(editor, QComboBox):
self.comboDel.setEditorData(editor, index)
else:
QItemDelegate.setEditorData(self, editor, index)
示例9: setEditorData
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
delegate = self.delegates.get(index.column())
if delegate is not None:
delegate.setEditorData(editor, index)
else:
QItemDelegate.setEditorData(self, editor, index)