File tree Expand file tree Collapse file tree 6 files changed +49
-0
lines changed Expand file tree Collapse file tree 6 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ Set the current value to the value defined by the clear value.
117
117
118
118
protected:
119
119
virtual void changeEvent( QEvent *event );
120
+ virtual void wheelEvent( QWheelEvent *event );
121
+
120
122
121
123
};
122
124
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ Set the current value to the value defined by the clear value.
117
117
118
118
virtual void changeEvent( QEvent *event );
119
119
virtual void paintEvent( QPaintEvent *event );
120
+ virtual void wheelEvent( QWheelEvent *event );
121
+
120
122
121
123
};
122
124
Original file line number Diff line number Diff line change @@ -62,6 +62,28 @@ void QgsDoubleSpinBox::changeEvent( QEvent *event )
62
62
mLineEdit ->setShowClearButton ( shouldShowClearForValue ( value () ) );
63
63
}
64
64
65
+ void QgsDoubleSpinBox::wheelEvent ( QWheelEvent *event )
66
+ {
67
+ double step = singleStep ();
68
+ if ( event->modifiers () & Qt::ControlModifier )
69
+ {
70
+ // ctrl modifier results in finer increments - 10% of usual step
71
+ double newStep = step / 10 ;
72
+ // but don't ever use an increment smaller than would be visible in the widget
73
+ // i.e. if showing 2 decimals, smallest increment will be 0.01
74
+ newStep = qMax ( newStep, pow ( 10.0 , 0.0 - decimals () ) );
75
+
76
+ setSingleStep ( newStep );
77
+
78
+ // clear control modifier before handing off event - Qt uses it for unwanted purposes
79
+ // (*increasing* step size, whereas QGIS UX convention is that control modifier
80
+ // results in finer changes!)
81
+ event->setModifiers ( event->modifiers () & ~Qt::ControlModifier );
82
+ }
83
+ QDoubleSpinBox::wheelEvent ( event );
84
+ setSingleStep ( step );
85
+ }
86
+
65
87
void QgsDoubleSpinBox::paintEvent ( QPaintEvent *event )
66
88
{
67
89
mLineEdit ->setShowClearButton ( shouldShowClearForValue ( value () ) );
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
125
125
126
126
protected:
127
127
virtual void changeEvent ( QEvent *event ) override ;
128
+ void wheelEvent ( QWheelEvent *event ) override ;
128
129
129
130
private slots:
130
131
void changed ( double value );
Original file line number Diff line number Diff line change @@ -68,6 +68,27 @@ void QgsSpinBox::paintEvent( QPaintEvent *event )
68
68
QSpinBox::paintEvent ( event );
69
69
}
70
70
71
+ void QgsSpinBox::wheelEvent ( QWheelEvent *event )
72
+ {
73
+ int step = singleStep ();
74
+ if ( event->modifiers () & Qt::ControlModifier )
75
+ {
76
+ // ctrl modifier results in finer increments - 10% of usual step
77
+ int newStep = step / 10 ;
78
+ // step should be at least 1
79
+ newStep = qMax ( newStep, 1 );
80
+
81
+ setSingleStep ( newStep );
82
+
83
+ // clear control modifier before handing off event - Qt uses it for unwanted purposes
84
+ // (*increasing* step size, whereas QGIS UX convention is that control modifier
85
+ // results in finer changes!)
86
+ event->setModifiers ( event->modifiers () & ~Qt::ControlModifier );
87
+ }
88
+ QSpinBox::wheelEvent ( event );
89
+ setSingleStep ( step );
90
+ }
91
+
71
92
void QgsSpinBox::changed ( int value )
72
93
{
73
94
mLineEdit ->setShowClearButton ( shouldShowClearForValue ( value ) );
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
126
126
127
127
virtual void changeEvent ( QEvent *event ) override ;
128
128
virtual void paintEvent ( QPaintEvent *event ) override ;
129
+ void wheelEvent ( QWheelEvent *event ) override ;
129
130
130
131
private slots:
131
132
void changed ( int value );
You can’t perform that action at this time.
0 commit comments