Change color of QLCD??
-
Set a QPalette with the colors you want. QLcdNumber is using the Light, Dark color role and the one set with QWidget::foregroundRole()
-
Hi
Welcome to the forums
As @Christian-Ehrlicher says, you can do that with QPalette like// get the palette auto palette = ui->lcdNumber->palette(); // foreground color palette.setColor(palette.WindowText, Qt::blue); // "light" border palette.setColor(palette.Light, QColor(255, 0, 0)); // "dark" border palette.setColor(palette.Dark, QColor(0, 255, 0)); // set the palette back ui->lcdNumber->setPalette(palette);
However, it looks best if you change to flat look
ui->lcdNumber->setSegmentStyle(QLCDNumber::Flat );
Or matches the dark/light with the base color so the 'raised' look still works.
-
@mrjj What's the "ui" you're using? Can't find it in my code...
And another question: I wrote a program with some pictures and so on, it's a racing game. I wahr to include QLCDNumber in this program to Show the score, but it doesn't works...
-
@QFelix said in [SOLVED] Change color of QLCD??:
@mrjj What's the "ui" you're using? Can't find it in my code...
If you create your code with Qt designer, you typically have a member
ui
in your class where you reference all your UI widgets. If you add them programmatically, then just ignore this ;)Regards
-
@QFelix said in Change color of QLCD??:
I wahr to include QLCDNumber in this program to Show the score, but it doesn't works...
Hi
How did yo use it ?
It should just work like any other widget you used.
But without some code , its hard to guess at what went wrong.