pyqt5 qmainwindow mouse move event

Solutions on MaxInterview for pyqt5 qmainwindow mouse move event by the best coders in the world

showing results for - "pyqt5 qmainwindow mouse move event"
Anna
16 Apr 2016
1#self.window.installEventFilter(app) needs to be run first for this to work
2#where window is the name of the QMainWindow and app is QApplication
3
4
5def eventFilter(self, source, event):
6    if event.type() == QtCore.QEvent.MouseMove:
7        if event.buttons() == QtCore.Qt.NoButton:
8            print("Simple mouse motion")
9        elif event.buttons() == QtCore.Qt.LeftButton:
10            print("Left click drag")
11        elif event.buttons() == QtCore.Qt.RightButton:
12            print("Right click drag")
13    elif event.type() == QtCore.QEvent.MouseButtonPress:
14        if event.button() == QtCore.Qt.LeftButton:
15            print("Press!")
16    return super(Window, self).eventFilter(source, event)