-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.8.3, 6.9.3
-
None
-
Windows 11
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.