[Python] Filter Event (Strg+Z) on Pyqtgraph ParameterTree

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    In my current application I am using pyqtgraphs ParameterTree that inherently implements an undo function for its elements. However this interferes with my global undo-stack, therefore I would like to filter Strg+Z events.

    ParameterTree inherits from QTreeWidget, therefore I tried some methods. Firstly, I tried to install an Event Filter (but I am not sure, if I have done this right to be fair).

    class FooterWidget(ParameterTree):
    """ Class for meta-properties of the map footer. """

    def __init__(self, main_gui, parent=None):
    super().__init__(parent=parent)
    self.viewport().installEventFilter(self)
    ...
    def eventFilter(self, object, event):
    if isinstance(event, QKeyEvent):
    return(event.key() & Qt.Key_Control > 0)
    return False


    This however does not prevent the Ctrl+Z action from being done. Also when I am filtering any keyPresses (i.e. eventFilter returns True in any case), I still see some input visible. This makes me guess that in fact the actual event is propagated to the children of the parameter tree before the actual event filter.

    Also a reimplementation of the keyPressEvent method did not help. Is there any way to interfere with the local undo of the Parameter Tree or rather its items?

    Continue reading...

Compartilhe esta Página