Search code examples
qtqwt

QwtPlot: pan with mouse button press and displaying values on curve at the same time


I have a QwtPlot and currently have it set up so I can pan on the graph by pressing and holding down the left mouse button. This is done in my eventFilter and handling the QEvent::MouseMove case.

I then wanted to be able to display the values of the curve when the mouse hovers over the curve. This is also done in the MouseMove event. I am able to do this by setting setMouseTracking(true), however, as a side effect, the window now pans by tracking my mouse movement.

I can only seem to be able to do one or the other, but not both at the same time. How can I allow for panning on my plot by pressing and holding the mouse button, while also displaying values based on where the mouse is position without causing the panning to be effected?


Solution

  • Whithout having mouseTracking enabled a mouse press is implied when receiving mouse move. When enabling it you also have to handle mouse press/release to know about if you are moving in pressed state.