How to undo an edit of a QListWidgetItem in PySide/PyQt?

后端 未结 3 1217
深忆病人
深忆病人 2020-12-12 02:06

Short version

How do you implement undo functionality for edits made on QListWidgetItems in PySide/PyQt?

Hint from a Qt

3条回答
  •  误落风尘
    2020-12-12 02:50

    I would do it like this:

    Create a custom QItemDelegate and use these two signals:

    • editorEvent
    • closeEditor

    On editorEvent: Save current state

    On closeEditor: Get new state and create a QUndoCommand that set the new state for Redo and the old state for Undo.

提交回复
热议问题