Skip to content

Commit 32fd79a

Browse files
committed
QAbstractSlider: fix invertedControls having no effect for left/right keys
There was a comment in the code that said: // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. It's not clear what that was referring to, but in its current state, a slider with invertedControls set to true will not behave as expected: pressing the left arrow key will decrease its value instead of increasing it, and vice versa for the right arrow key. As stated in the documentation (and by its name), invertedAppearance only controls the appearance of the slider, and not the effect of key events. Remove the comment and use invertedControls instead. Change-Id: I13296cbda9244413978ef0d7f0856065f74fd0bf Fixes: QTBUG-25988 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
1 parent 35602d7 commit 32fd79a

File tree

2 files changed

+491
-8
lines changed

2 files changed

+491
-8
lines changed

src/widgets/widgets/qabstractslider.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
829829
break;
830830
#endif
831831

832-
// It seems we need to use invertedAppearance for Left and right, otherwise, things look weird.
833832
case Qt::Key_Left:
834833
#ifdef QT_KEYPAD_NAVIGATION
835834
// In QApplication::KeypadNavigationDirectional, we want to change the slider
@@ -848,9 +847,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
848847
else
849848
#endif
850849
if (isRightToLeft())
851-
action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
850+
action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
852851
else
853-
action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
852+
action = !d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
854853
break;
855854
case Qt::Key_Right:
856855
#ifdef QT_KEYPAD_NAVIGATION
@@ -868,9 +867,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
868867
else
869868
#endif
870869
if (isRightToLeft())
871-
action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
870+
action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
872871
else
873-
action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
872+
action = !d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
874873
break;
875874
case Qt::Key_Up:
876875
#ifdef QT_KEYPAD_NAVIGATION

0 commit comments

Comments
 (0)