PlotPyStack / PythonQwt

Qt plotting widgets for Python (pure Python reimplementation of Qwt C++ library)
https://pypi.org/project/PythonQwt/
Other
86 stars 25 forks source link

`QwtPlot.setMouseTracking` is ignored #88

Open ZeeD opened 4 weeks ago

ZeeD commented 4 weeks ago

I want to detect the mouse move events over my qwt plot.

According to mouseMoveEvent docs:

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

To enable the mouse tracking it should be enough to invoke setMouseTracking(True) but it seems to me that it is ignored.

from qwt.plot import QwtPlot
from PySide6.QtGui import QMouseEvent

class MyPlot(QwtPlot):
    def __init__(self) -> None:
        super().__init__()
        self.setMouseTracking(True)
    def mouseMoveEvent(self, event: QMouseEvent) -> None:
        print(event) # dummy implementation

I see the events in the stdout only if I keep the mouse button pressed, not just on "hovering" over the plot

ZeeD commented 4 weeks ago

as a workaround, if I also set self.canvas().setMouseTracking(True) then mouseMoveEvent is invoked, but I had to digg inside PwtPlot to check how it worked