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. Unable to change the background color of DockLabel
Forum Updated to NodeBB v4.3 + New Features

Unable to change the background color of DockLabel

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 146 Views 2 Watching
  • 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.
  • B Offline
    B Offline
    bea1999
    wrote on last edited by
    #1

    Hello, i tried to change the background color of DockLabel (class from anaconda package) using
    self.ImageDock.label.setStyleSheet("background-color: #04B2E2; color: white;")
    the default color is purple : #66c and i wanna change it to blue #04B2E2
    BUT IT DIDNT WORK!
    changing it from the actual package works but i dont wanna modify the class directly.
    Any idea how can i do that dynamically?? thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Where does that class come from ?
      Which Python bindings are you using ?
      Can you provide a minimal runnable script that shows this issue ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bea1999
        wrote on last edited by
        #3

        sure!
        [link text](from PyQt5.QtWidgets import QApplication, QMainWindow
        from pyqtgraph.dockarea import Dock, DockArea
        import pyqtgraph as pg
        import sys

        class DockApp(QMainWindow):
        def init(self):
        super().init()
        self.setWindowTitle("Dockable Display App")
        self.setGeometry(100, 100, 800, 600)

            self.area = DockArea()
            self.setCentralWidget(self.area)
            
            self.set_dock_default()
        
        def set_dock_default(self):
            """Sets up the dock with a display window."""
            self.image_dock = Dock(name="Display Dock", size=(1, 1))
            self.image_dock.label.setStyleSheet("background-color: #04B2E2;") #change to blu but doesn't work
            self.display_window = pg.PlotWidget(title="Image Display")
            self.display_window.getViewBox().invertY(True)  # Inverting Y axis
            
            self.image_dock.addWidget(self.display_window)
            self.area.addDock(self.image_dock, "top")
        

        if name == "main":
        app = QApplication(sys.argv)
        window = DockApp()
        window.show()
        sys.exit(app.exec_())
        )

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bea1999
          wrote on last edited by
          #4

          sorry i messed up the code in the first reply, i'm new here haha

          from PyQt5.QtWidgets import QApplication, QMainWindow
          from pyqtgraph.dockarea import Dock, DockArea
          import pyqtgraph as pg
          import sys
          
          class DockApp(QMainWindow):
              def __init__(self):
                  super().__init__()
                  self.setWindowTitle("Dockable Display App")
                  self.setGeometry(100, 100, 800, 600)
                  
                  self.area = DockArea()
                  self.setCentralWidget(self.area)
                  
                  self.set_dock_default()
          
              def set_dock_default(self):
                  """Sets up the dock with a display window."""
                  self.image_dock = Dock(name="Display Dock", size=(1, 1))
                  self.image_dock.label.setStyleSheet("background-color: #04B2E2;") #change to blu but doesn't work
                  self.display_window = pg.PlotWidget(title="Image Display")
                  self.display_window.getViewBox().invertY(True)  # Inverting Y axis
                  
                  self.image_dock.addWidget(self.display_window)
                  self.area.addDock(self.image_dock, "top")
          
          if __name__ == "__main__":
              app = QApplication(sys.argv)
              window = DockApp()
              window.show()
              sys.exit(app.exec_())
          
          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