Customized QScrollBar
-
i want to customize a QScrollbar; like rounding its margins and ... .
but i can not use StyleSheet for some reason.
is there a way to do it? perhaps with paintevent or QPalette.@mahd96
no, native style internals are not accessible.
The only thing without using stylesheets is to overrride the QScrollBar's paintEvent() to do the whole drawing yourself or by implementing a QProxyStyle and again do the painting yourself. -
Hi
why can't you use a stylesheet? -
i am working on a quite big application and now we start to have lots of crashes in drawEvents that are activated in paintEvents, generaly rendering seems to be issue in this case.
we tend to replace css and stylesheet with QPalette.
but css supports some sizing hints and i am looking to replace them. some hints like radius,ScrollbarHeight and... . -
i am working on a quite big application and now we start to have lots of crashes in drawEvents that are activated in paintEvents, generaly rendering seems to be issue in this case.
we tend to replace css and stylesheet with QPalette.
but css supports some sizing hints and i am looking to replace them. some hints like radius,ScrollbarHeight and... .@mahd96
Hmm ok. What Qt version?
I saw some reports about stylesheet and crashes for Qt5.12.
(the bug id escapes me)Well the paintEvent is like
void QSlider::paintEvent(QPaintEvent *) { Q_D(QSlider); QPainter p(this); QStyleOptionSlider opt; initStyleOption(&opt); 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); }so i fear the things you want to alter is inside drawComplexControl, however
QStyleOptionSlider does control some of it.https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qslider.cpp.html