Answer the question
In order to leave comments, you need to log in
PyQt5 - mouseMoveEvent does not always work (eventFilter does not work at all), how to track the mouse?
The task is to track the mouse on a set of QWidgets (the decorator is hung on mouseMoveEvent and does its job). The problem is that the event only fires on the bare form. And there are such widgets, where some element occupies the entire form, so the event does not work at all. As far as I understood, the only option is to catch the eventFilter. But it doesn't work at all. So how to catch a mouse? What am I doing wrong? Here is an example with an eventFilter that doesn't work:
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtCore import QObject
class SomeFilter(QObject):
def eventFilter(self, obj, ev):
print("Event filtering ok")
return False
class MainWidget(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.installEventFilter(SomeFilter())
app = QApplication(sys.argv)
w = MainWidget()
w.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question