pyqt5 qmainwindow mouse move event adding 0 0 code example

Example: pyqt5 qmainwindow mouse move event

#self.window.installEventFilter(app) needs to be run first for this to work
#where window is the name of the QMainWindow and app is QApplication


def eventFilter(self, source, event):
    if event.type() == QtCore.QEvent.MouseMove:
        if event.buttons() == QtCore.Qt.NoButton:
            print("Simple mouse motion")
        elif event.buttons() == QtCore.Qt.LeftButton:
            print("Left click drag")
        elif event.buttons() == QtCore.Qt.RightButton:
            print("Right click drag")
    elif event.type() == QtCore.QEvent.MouseButtonPress:
        if event.button() == QtCore.Qt.LeftButton:
            print("Press!")
    return super(Window, self).eventFilter(source, event)