Changing the Digit Color of QLCD Number
Actually, it works. QLCDNumber
, by default, paints digits in "raised" style. For small sizes, these borders that give the raised effect will mostly cover the digit and you won't see the normal color. If you make it larger, it will show:
If you don't want this "raised" effect, you can turn it off with setSegmentStyle
:
lcd.setSegmentStyle(QtGui.QLCDNumber.Flat)
On the other hand, if you want the "raised" effect but want to control it, you need to do it via QPalette
. QPalette.Light
and QPalette.Dark
are the two colors that control those borders.
# 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)