def modify_item(self, text, val, match_to_use=0):
"""
modify the current item and set its displayed value to 'val'
"""
idxlist = self.widget.model.match(self.widget.model.index(0, 0), Qt.DisplayRole, text, match_to_use + 1, Qt.MatchExactly | Qt.MatchRecursive)
if not idxlist:
raise RuntimeError("Item with text '{}' not found".format(text))
idx = idxlist[match_to_use]
self.widget.view.setCurrentIndex(idx)
idx = idx.sibling(idx.row(), 1)
self.widget.view.edit(idx)
editor = self.widget.view.focusWidget()
if not editor:
print(app.focusWidget())
print("NO EDITOR WIDGET")
#QTest.keyClick(self.widget.view, Qt.Key_Return)
from IPython import embed
embed()
raise RuntimeError("Could not get editor widget!, it does not have the focus")
if hasattr(editor, "_current_node"):
editor._current_node = val
elif hasattr(editor, "setCurrentText"):
editor.setCurrentText(val)
else:
editor.setText(val)
self.widget.view.commitData(editor)
self.widget.view.closeEditor(editor, QAbstractItemDelegate.NoHint)
self.widget.view.reset()
评论列表
文章目录