-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.8.3, 6.9.3
-
None
-
Windows 11
-
1f5a45116 (dev), 74063980a (6.10)
In QStyleSheetStyle::drawComplexControl (src\qtbase\src\widgets\styles\qstylesheetstyle.cpp:3465) the code path for drawing the SC_SliderHandle sub-control of CC_Slider also draws the PseudoElement_SliderSubPage, and PseudoElement_SliderAddPage elements even when the groove sub-control is not requested. Further, from inspection, it appears the SubPage and AddPage will not be drawn if only the groove sub-control is requested.
Reproducing code.
class QDrawComplexControlBug : public QSlider { using QSlider::QSlider; void paintEvent(QPaintEvent* event) override { QStylePainter p(this); QStyleOptionSlider option; initStyleOption(&option); option.subControls = QStyle::SC_SliderHandle; p.drawComplexControl(QStyle::CC_Slider, option); } }; int main(int argc, char* argv[]) { auto app = QApplication(argc, argv); app.setStyleSheet("QSlider::handle {border:2px solid; border-radius : 5px; } QSlider::add-page {background: #223377; } QSlider::sub-page {background: #883366; }"); auto window = new QMainWindow(); auto w = new QWidget(); auto layout = new QVBoxLayout(w); w->setLayout(layout); auto slider = new QDrawComplexControlBug(Qt::Horizontal, w); slider->setRange(0, 100); slider->setValue(50); layout->addWidget(slider); window->setCentralWidget(w); window->show(); return app.exec(); }
If you remove the line app.setStyleSheet(...), then only the handle is rendered as expected.
| For Gerrit Dashboard: QTBUG-141157 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 685021,2 | QStyleSheetStyle: don't draw SC_SliderGroove when not asked for | dev | qt/qtbase | Status: MERGED | +2 | 0 |
| 685745,2 | QStyleSheetStyle: don't draw SC_SliderGroove when not asked for | 6.10 | qt/qtbase | Status: MERGED | +2 | 0 |