title: PyQt4 QSlider groove color customization
body: <p>I am currently doing a GUI using PyQt4. My question is : how do I manage to have different background colors for <code>QSlider::groove:horizontal</code> over a specific range of index slider values ? Here is a minimal working example :</p>
  
  <pre><code>from PyQt4 import QtCore, QtGui
  #%%
  data_range = [0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0]
  color_range =['black','black','black','black','white','white',\
                'white','black','black','white','white','black']
  
  class MyWidget(QtGui.QWidget):
      def __init__(self):
          super(MyWidget, self).__init__()
          self.initUI()
  
      def initUI(self):
          self.setGeometry(600,300,500,100)
  
          # Definition of the slider
          self.slider = QtGui.QSlider(minimum=0,\
          maximum= len(data_range)-1,\ 
          orientation=QtCore.Qt.Horizontal,\
          tickInterval=1)
  
          # Trying to customize it
          self.slider.setStyleSheet(\
          "QSlider::groove:horizontal {\
          border: 1px solid #999999;\
          height: 8px; \
          background: white;\
          margin: -4px 0;\
          }QSlider::handle:horizontal {\
          background-color: red;\
          border: 1px solid #5c5c5c;\
          border-radius: 0px;\
          border-color: black;\
          height: 8px;\
          width: 6px;\
          margin: -8px 2; \
          }")
         grid = QtGui.QGridLayout(self)
         hbox = QtGui.QHBoxLayout()
         hbox.addWidget(self.slider)
         grid.addLayout(hbox, 3, 0, 1, 3)
  
  
  def main():
      import sys
      app = QtGui.QApplication(sys.argv)
      w = MyWidget()
      w.show()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>In this case, the Qslider's groove should be black from 0 : 4, white from 4 : 7, black from 7 : 9 and so on.</p>
  
  <p>I did try to use <code>self.slider.setStyleSheet()</code> following the <a href="https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qslider" rel="nofollow noreferrer">qt documentation</a> but in vain ...</p>
  
  <p>Any help or alternative ideas to decorate  the slider would be greatly appreciated.</p>