Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QSlider color
Qt 6.11 is out! See what's new in the release blog

QSlider color

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 943 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Captain Haddock
    wrote on last edited by
    #1

    In the example below when I set the slider value, the slider bar below the indicator appears orange. How can I set it to a different color?

    import sys
    from PyQt6 import QtWidgets, QtCore
    
    
    class MainWindow(QtWidgets.QMainWindow):
    
        def __init__(self):
            super().__init__()
            self.setFixedWidth(400)
            self.setFixedHeight(400)
            self.setStyleSheet("background-color: silver")
    
            slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical)
            slider.setFixedHeight(400)
            slider.setValue(50)
    
            self.layout().addWidget(slider)
    
    
    if __name__ == '__main__':
        app = QtWidgets.QApplication(sys.argv)
        ex = MainWindow()
        ex.show()
        sys.exit(app.exec())
    
    JonBJ 1 Reply Last reply
    0
    • C Captain Haddock

      In the example below when I set the slider value, the slider bar below the indicator appears orange. How can I set it to a different color?

      import sys
      from PyQt6 import QtWidgets, QtCore
      
      
      class MainWindow(QtWidgets.QMainWindow):
      
          def __init__(self):
              super().__init__()
              self.setFixedWidth(400)
              self.setFixedHeight(400)
              self.setStyleSheet("background-color: silver")
      
              slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical)
              slider.setFixedHeight(400)
              slider.setValue(50)
      
              self.layout().addWidget(slider)
      
      
      if __name__ == '__main__':
          app = QtWidgets.QApplication(sys.argv)
          ex = MainWindow()
          ex.show()
          sys.exit(app.exec())
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Captain-Haddock
      Try setting the stylesheet on the slider.
      I think per https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qslider you need to select the ::groove?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved