QLCD Number Digit Color Change

I want to change the background color and numbers QLCDNumberin Qt Designer, and I'm going to use this project (GUI) in my Python program.

Some people said they could get my add stylesheet in Qt-Designer.

QLCDNumber{color:rgb(85, 85, 255);background-color:rgb(0, 170, 255);}

Successfully for the background color is not for the color of the numbers.

How can I get the color of the numbers

thank


I cannot use the last two setColor (for a light border and a dark border). I generated python code (for GUI) from Qt4 Designer using the pyuic4 tool. I added the codes to my python code file (ending in .py not.ui) as follows

self.palette = self.withpalette.palette()
self.palette.setColor(QtGui.Palette.WindowText,QtGui.QColor(85,85,255))
self.palette.setColor(QtGui.Palette.Background,QtGui.QColor(0,170,255))
self.palette.setColor(QtGui.Palette.Light,QtGui.QColor(255,0,0))
self.palette.setColor(QtGui.Palette.Dark,QtGui.QColor(0,255,0))
self.withpalette.setPalette(self.palette)
+5
source share
1 answer

, . QLCDNumber, , "". , , , . , :

QLCDNumber

"" , setSegmentStyle:

lcd.setSegmentStyle(QtGui.QLCDNumber.Flat)

Flat QLCDNumber

, "" , , QPalette, QPalette.Light QPalette.Dark - , .

# get the palette
palette = lcd.palette()

# foreground color
palette.setColor(palette.WindowText, QtGui.QColor(85, 85, 255))
# background color
palette.setColor(palette.Background, QtGui.QColor(0, 170, 255))
# "light" border
palette.setColor(palette.Light, QtGui.QColor(255, 0, 0))
# "dark" border
palette.setColor(palette.Dark, QtGui.QColor(0, 255, 0))

# set the palette
lcd.setPalette(palette)

QLCDNumber custom QPalette

+6

All Articles