本文整理汇总了Python中PyQt5.QtWidgets.QStyledItemDelegate.setModelData方法的典型用法代码示例。如果您正苦于以下问题:Python QStyledItemDelegate.setModelData方法的具体用法?Python QStyledItemDelegate.setModelData怎么用?Python QStyledItemDelegate.setModelData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStyledItemDelegate
的用法示例。
在下文中一共展示了QStyledItemDelegate.setModelData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redo
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def redo(self):
if self.first_time == True:
QStyledItemDelegate.setModelData(self.parent, self.editor, self.model,
self.index) # this is very important this is the one that changes the text
self.redo_value = self.index.model().data(self.index, Qt.DisplayRole)
self.first_time = False
elif self.first_time == False:
self.model.setData(self.index, self.redo_value)
self.model.dataChanged.emit(self.index, self.index)
示例2: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, idx):
name = idx.sibling(idx.row(), 0).data()
if self.editors[name][0] == self.TEXT_DELEGATE:
QStyledItemDelegate.setModelData(self, editor, model, idx)
else:
value = editor.currentText()
values = self.editors[name][1]
if value not in values:
values.append(value)
QStyledItemDelegate.setModelData(self, editor, model, idx)
示例3: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor: QWidget,
model: QAbstractItemModel,
model_index: QModelIndex):
column = model_index.column()
if column == NAME_COL: # Part Name
text_QString = editor.text()
model.setData(model_index, text_QString, Qt.EditRole)
# elif column == VISIBLE_COL: # Visibility
# value = editor.isChecked()
# model.setData(model_index, value, Qt.EditRole)
elif column == COLOR_COL: # Color
color = editor.currentColor()
model.setData(model_index, color.name(), Qt.EditRole)
else:
QStyledItemDelegate.setModelData(self, editor, model, model_index)
示例4: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, index):
if index.column() in DATE_TIME_COLUMN_LIST:
editor.interpretText()
str_value = editor.text()
model.setData(index, str_value, Qt.EditRole)
else:
return QStyledItemDelegate.setModelData(self, editor, model, index)
示例5: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, idx):
"""
Called when editor has finished editing data
Here we call the default implementation and save our values
"""
QStyledItemDelegate.setModelData(self, editor, model, idx)
root = model.item(0, 0)
uries = []
count = 0
while True:
child = root.child(count, 2)
count += 1
if not child:
break
uries.append(child.text())
logger.info("Writting namespace array: %s", uries)
self.widget.node.set_value(uries)
示例6: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, index):
# This call below is to give a chance to the editor to tweak its content a little bit before
# we send it to the model.
if hasattr(editor, 'prepareDataForCommit'):
editor.prepareDataForCommit()
QStyledItemDelegate.setModelData(self, editor, model, index)
示例7: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, index):
layer = index.data()
if isinstance(layer, Layer):
model.setData(index, editor.layer)
else:
QStyledItemDelegate.setModelData(self, editor, model, index)
示例8: setModelData
# 需要导入模块: from PyQt5.QtWidgets import QStyledItemDelegate [as 别名]
# 或者: from PyQt5.QtWidgets.QStyledItemDelegate import setModelData [as 别名]
def setModelData(self, editor, model, idx):
value = editor.currentText() if editor.metaObject().className() == 'TComboBox' else editor.text()
prev_val = idx.sibling(idx.row(), 0).data()
self.edit_finished.emit( [idx, prev_val, value ] )
QStyledItemDelegate.setModelData(self, editor, model, idx)