実際には、スタイル シートとサブコントロールのborder-image
プロパティだけで実現できgroove
ます。
たとえば、次のようなボーダー画像を使用します。

何がどこにあるのかよくわかるように、B は幅 10 ピクセル、スペースは 2、A は幅 12 ピクセルです。
QSlider::groove {
border-image: url(:/slider-decoration.png) 0 12 0 10;
border-left: 10px solid transparent;
border-right: 12px solid transparent;
}
QSlider::handle {
width: 8px;
background-color: green;
}
これにより、期待どおりの結果が得られます。

ただし、このソリューションには小さな問題があります。マウスは境界線の存在を無視し、ハンドル位置とマウス位置の間の両端付近にオフセットがあります。したがって、それを避けるために、ハンドルはどちらかの側まで移動する必要がありますが、透明な境界線を追加して、画像の境界線の直前で停止しているように見せます:
QSlider::groove {
border-image: url(:/slider-decoration.png) 0 12 0 10;
border-left: 10px;
border-right: 12px;
}
QSlider::handle {
width: 8px;
/* add borders to the handle that will sit above the groove border */
border-right: 10px solid transparent;
border-left: 12px solid transparent;
/* negative margins to allow the handle borders
to go past the groove borders */
margin-right: -10px;
margin-left: -12px;
background-color: green;
/* make the background color fill the content, not the border */
background-clip: content;
}