Display drag/move mouse pointer when dragging cursors

Enables mouse tracking on PlotView to get mouse move events
even when not dragging.

Passes through Leave events to handle the case where the cursor
is near the edge of the widget and the mouse leaves the widget
without generating a mouse move event that isn't on the cursor.

Passes in mouse cursor shape to Cursor to define whether it should
be a horizontal resize, vertical resize or move (resize all).

Qt handles the case where the cursor is dragged off screen and
does not generate a Leave event while draggin (<3 Qt).
This commit is contained in:
Mike Walters
2016-08-12 15:42:24 +01:00
parent 172ddee5c4
commit ec7c42a38c
5 changed files with 32 additions and 16 deletions

View File

@@ -30,6 +30,7 @@ PlotView::PlotView(InputSource *input) : cursors(this), viewRange({0, 0})
{
mainSampleSource = input;
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setMouseTracking(true);
enableCursors(false);
enableTimeScale(true);
connect(&cursors, SIGNAL(cursorsMoved()), this, SLOT(cursorsMoved()));
@@ -131,7 +132,8 @@ bool PlotView::eventFilter(QObject * obj, QEvent *event)
// Pass mouse events to individual plot objects
if (event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseMove ||
event->type() == QEvent::MouseButtonRelease) {
event->type() == QEvent::MouseButtonRelease ||
event->type() == QEvent::Leave) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);