diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-11-10 15:04:08 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-11 22:13:58 +0000 |
commit | e816094682d2665b795e6e782f93fef5c1f08a65 (patch) | |
tree | 9040e816fba6844eb42289d222fd524a21cd1888 /src | |
parent | 4a31673d0714f1b76b12dc502365daee4bfe3171 (diff) |
QSlider: Always set the sunken state and the active control
initStyleOption should initialize the state based on which controls are
pressed or hovered, not only when painting but also when calling other
style APIs.
Task-number: QTBUG-98093
Change-Id: I482793b7de38657aa36a20d0abab8845155ad0e9
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit c7e8133a95220e0ce96171024e34de8c53975b9c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/widgets/qslider.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp index d2eeec494a..22a6d323fe 100644 --- a/src/widgets/widgets/qslider.cpp +++ b/src/widgets/widgets/qslider.cpp @@ -155,6 +155,13 @@ void QSlider::initStyleOption(QStyleOptionSlider *option) const option->pageStep = d->pageStep; if (d->orientation == Qt::Horizontal) option->state |= QStyle::State_Horizontal; + + if (d->pressedControl) { + option->activeSubControls = d->pressedControl; + option->state |= QStyle::State_Sunken; + } else { + option->activeSubControls = d->hoverControl; + } } bool QSliderPrivate::updateHoverControl(const QPoint &pos) @@ -317,12 +324,6 @@ void QSlider::paintEvent(QPaintEvent *) opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; if (d->tickPosition != NoTicks) opt.subControls |= QStyle::SC_SliderTickmarks; - if (d->pressedControl) { - opt.activeSubControls = d->pressedControl; - opt.state |= QStyle::State_Sunken; - } else { - opt.activeSubControls = d->hoverControl; - } style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this); } |