Important: Please read the Qt Code of Conduct -

MouseReleaseEvent gets called twice

  • Hey,

    So I have this minimal example reproducing my problem:

    from PyQt5 import QtWidgets as qtw
    class Scene(qtw.QGraphicsScene):
        def mousePressEvent(self, event: qtw.QGraphicsSceneMouseEvent) -> None:
        def mouseReleaseEvent(self, event: qtw.QGraphicsSceneMouseEvent) -> None:
    class MainWindow(qtw.QMainWindow):
        def __init__(self, parent=None):
            super(MainWindow, self).__init__(parent)
            scene = Scene()
            view = qtw.QGraphicsView(scene)
            centralWidget = qtw.QWidget()
            centralLayout = qtw.QHBoxLayout(centralWidget)
    if __name__ == '__main__':
        import sys
        app = qtw.QApplication(sys.argv)
        mainWindow = MainWindow()

    When I run the programm, and doubletap the left mouse button fast, I get the output


    Which is not what I expect it to do. It should rather print pressed, released, pressed, released.
    Any idea? Im kinda stuck on this one

  • Lifetime Qt Champion


    You should add:

    • the PyQt5 version you are using
    • the Qt version
    • the OS
    • the hardware for your double tap

  • @SGaist

    • 5.14.0
    • That should be 5.14.0 aswell
    • Windows 10 Education
    • Steelseries rival 100

    A quick fix I found was to call the mousePressEvent in the mouseDoubleClickEvent method, but Im not sure if thats supposed to be like that

  • @Thomas-Stein said in MouseReleaseEvent gets called twice:

    Steelseries rival 100

    So it's actually just a "normal" doubleClick instead of tap?
    "Tap" suggests, that you are using a touchscreen, which isn't the case :)

    Do you face the same behavior, when you use a standard mouse?

  • @Pl45m4


    Yes sorry, my bad. I shouldve used click instead of tap, you are right. And yes, I do face the same behaviour

  • @Thomas-Stein said in MouseReleaseEvent gets called twice:

    And yes, I do face the same behaviour

    My idea was, that your (gaming) mouse has some software or special double click behavior which causes your weird debug output...

  • @Pl45m4
    Well I tried double tapping my laptops touchpad, and it still get the same output

Log in to reply