I suggest you to subclass QSlider and reimplement paintEvent as the following:
void My_slider::paintEvent(QPaintEvent *ev) {
QStyleOptionSlider opt;
initStyleOption(&opt);
opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
if (tickPosition() != NoTicks) {
opt.subControls |= QStyle::SC_SliderTickmarks;
}
QRect groove_rect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
qDebug() << groove_rect;
QSlider::paintEvent(ev);
QRect rect(groove_rect.left() + 0.2 * groove_rect.width(), groove_rect.top(), 0.6 * groove_rect.width(), groove_rect.height());
QPainter painter(this);
painter.fillRect(rect, QBrush(Qt::red));
}