diff --git a/python/gui/auto_generated/editorwidgets/qgsdoublespinbox.sip.in b/python/gui/auto_generated/editorwidgets/qgsdoublespinbox.sip.in index dd6d5eb5edb..4ddd79e8e75 100644 --- a/python/gui/auto_generated/editorwidgets/qgsdoublespinbox.sip.in +++ b/python/gui/auto_generated/editorwidgets/qgsdoublespinbox.sip.in @@ -145,6 +145,8 @@ is equal to minimum(). Typical use is to indicate that this choice has a special virtual void wheelEvent( QWheelEvent *event ); + virtual void timerEvent( QTimerEvent *event ); + }; diff --git a/src/gui/editorwidgets/qgsdoublespinbox.cpp b/src/gui/editorwidgets/qgsdoublespinbox.cpp index e7c875c0569..0861721ce2c 100644 --- a/src/gui/editorwidgets/qgsdoublespinbox.cpp +++ b/src/gui/editorwidgets/qgsdoublespinbox.cpp @@ -93,6 +93,17 @@ void QgsDoubleSpinBox::wheelEvent( QWheelEvent *event ) setSingleStep( step ); } +void QgsDoubleSpinBox::timerEvent( QTimerEvent *event ) +{ + // Process all events, which may include a mouse release event + // Only allow the timer to trigger additional value changes if the user + // has in fact held the mouse button, rather than the timer expiry + // simply appearing before the mouse release in the event queue + qApp->processEvents(); + if ( QApplication::mouseButtons() & Qt::LeftButton ) + QDoubleSpinBox::timerEvent( event ); +} + void QgsDoubleSpinBox::paintEvent( QPaintEvent *event ) { mLineEdit->setShowClearButton( shouldShowClearForValue( value() ) ); diff --git a/src/gui/editorwidgets/qgsdoublespinbox.h b/src/gui/editorwidgets/qgsdoublespinbox.h index af61b22b0c4..4b3cbf31720 100644 --- a/src/gui/editorwidgets/qgsdoublespinbox.h +++ b/src/gui/editorwidgets/qgsdoublespinbox.h @@ -146,6 +146,10 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox protected: void changeEvent( QEvent *event ) override; void wheelEvent( QWheelEvent *event ) override; + // This is required because private implementation of + // QAbstractSpinBoxPrivate may trigger a second + // undesired event from the auto-repeat mouse timer + void timerEvent( QTimerEvent *event ) override; private slots: void changed( double value );