python - Correct way to use the signal closeEditor in QStyledItemDelegate? -
i overriding qstyleditemdelegate class , reimplementing eventfilter function can customize editor behavior when tab press detected. however, following not working. correct way invoke closeeditor signal?
class customdelegate(qstyleditemdelegate): def __init__(self, parent=none): super(customdelegate, self).__init__(parent) def eventfilter(self, editor, event): if (event.type() == qevent.keypress , event.key() == qt.key_tab): print "tab captured in editor" self.commitdata.emit(editor) #this working self.closeeditor.emit(editor) #this not seem anything?? return true return qstyleditemdelegate.eventfilter(self,editor,event)
this old question, ran same issue , found question.
i solved changing the
self.closeeditor.emit(editor)
line to
self.closeeditor.emit(editor, qabstractitemdelegate.nohint)
.
the commitdata
call setmodeldata
. if don't call closeeditor
, setmodeldata
called again editor close.
Comments
Post a Comment