Important: Please read the Qt Code of Conduct -

PySide2 contextMenuEvent and mouseMoveEvent clash

  • Hey everyone.

    I'am trying to convert a UI from PySide to PySide2 but I am having a hard time with the contextMenuEvent. Everyything works fine with PySide but in PySide2 in some cases the events seems to be confused.

    # Traceback (most recent call last):
    #   File "/sw/dev/legoffl/pythonDev/", line 919, in mouseMoveEvent
    #     super(PickerView, self).mouseMoveEvent(event)
    # TypeError: # 'PySide2.QtWidgets.QGraphicsView.mouseMoveEvent' called with wrong argument types:
    #   PySide2.QtWidgets.QGraphicsView.mouseMoveEvent(PySide2.QtGui.QContextMenuEvent)
    # Supported signatures:
    # PySide2.QtWidgets.QGraphicsView.mouseMoveEvent(PySide2.QtGui.QMouseEvent)

    From what I understand, It seems that the contextMenu event is still the one detected when the mouse is moving. This only happens for some entries of my menu. Now the question is WHY ? PySide version work perfectly. What has changed ???
    Is tthere a new trick with PySide2 ???


  • Lifetime Qt Champion

    @Goffer So, you're handling events by yourself? Can you show the code?

  • Sorry, I am not allowed to share the code as it' company property.

    I am simply subclassing a QGrapgicsView and overriding ContextMenuEvent and MouseMoveEvent to add some features, nothing fancy.

  • Lifetime Qt Champion

    @Goffer Well, without code it is hard to help...

Log in to reply