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. Pick-to: 6.2 Task-number: QTBUG-98093 Change-Id: I482793b7de38657aa36a20d0abab8845155ad0e9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>bb10
parent
0a8a4698d6
commit
c7e8133a95
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue