A
A
Alexey2018-02-17 15:02:27
Python
Alexey, 2018-02-17 15:02:27

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_())

The fact that MainWidget is here is not important. Tried to hang up on QWidget, on elements in QWidget - all is useless.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2018-02-17
@InterVi

Solved: https://www.linux.org.ru/forum/development/14031223

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question