本文整理汇总了Python中PyQt5.QtWidgets.QStyledItemDelegate.setEditorData方法的典型用法代码示例。如果您正苦于以下问题:Python QStyledItemDelegate.setEditorData方法的具体用法?Python QStyledItemDelegate.setEditorData怎么用?Python QStyledItemDelegate.setEditorData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStyledItemDelegate
的用法示例。
在下文中一共展示了QStyledItemDelegate.setEditorData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
text = index.model().data(index, Qt.DisplayRole)
if index.column() == residNum:
if text is None:
value = 0
elif isinstance(text, int):
value = text
else:
value = int(re.sub(r"[., ]", "", text))
editor.setValue(value)
# elif index.column() == residName:
# editor.setText(text)
elif index.column() == atomName:
editor.setText(text)
elif index.column() == atomNum:
if text is None:
value = 0
elif isinstance(text, int):
value = text
else:
value = int(re.sub(r"[., ]", "", text))
editor.setValue(value)
elif index.column() in (X, Y, Z):
if text is None:
value = 0
elif isinstance(text, int):
value = text
else:
value = float(text)
editor.setValue(value)
else:
QStyledItemDelegate.setEditorData(self, editor, index)
示例2: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
text = index.model().data(index, Qt.DisplayRole)
if index.column() == name:
editor.setText(text)
# elif index.column() == resName:
# editor.setItemText(text)
elif index.column() == ChainID:
editor.setText(text)
elif index.column() == resNum:
if text is None:
value = 0
elif isinstance(text, int):
value = text
else:
value = int(re.sub(r"[., ]", "", text))
editor.setValue(value)
elif index.column() in (serial, X, Y, Z, occupancy, charge):
if text is None:
value = 0
elif isinstance(text, int):
value = text
else:
try:
value = float(text)
except:
value = 0
editor.setValue(value)
elif index.column() == element:
editor.setText(text)
else:
QStyledItemDelegate.setEditorData(self, editor, index)
示例3: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, idx):
#print(editor.metaObject().className() )
name = idx.sibling(idx.row(), 0).data()
if self.editors[name][0] == self.TEXT_DELEGATE:
QStyledItemDelegate.setEditorData(self, editor, idx)
else:
value = idx.model().data(idx, Qt.EditRole)
editor.set_index(value)
示例4: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor: QWidget, model_index: QModelIndex):
column = model_index.column()
if column == NAME_COL: # Part Name
text_QString = model_index.model().data(model_index, Qt.EditRole)
editor.setText(text_QString)
# elif column == VISIBLE_COL: # Visibility
# value = model_index.model().data(model_index, Qt.EditRole)
# editor.setChecked(value)
elif column == COLOR_COL: # Color
value = model_index.model().data(model_index, Qt.EditRole)
editor.setCurrentColor(QColor(value))
else:
QStyledItemDelegate.setEditorData(self, editor, model_index)
示例5: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
layer = index.data()
if isinstance(layer, Layer):
editor.layer = layer
else:
QStyledItemDelegate.setEditorData(self, editor, index)
示例6: setEditorData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setEditorData [as 别名]
def setEditorData(self, editor, index):
if index.column() in DATE_TIME_COLUMN_LIST:
value = index.model().data(index, Qt.EditRole)
editor.setDateTime(value) # value cannot be a string, it have to be a datetime...
else:
return QStyledItemDelegate.setEditorData(self, editor, index)