Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SetPalette() for QLCDnumber



  • Hi everyone, I tried to change the font color of the QLCDnumber into some certain color such as red and dark yellow. (Such as the code below)

        ui->TestQLCD->setSegmentStyle(QLCDNumber::Filled);
        ui->TestQLCD->setPalette(Qt::darkYellow);
    

    I understand that setPalette(Qt:: LALALA) where LALALA is a fixed range of color.
    However, I would like to change to certain other colour such as Orange or Brown. Do I have to manipulate QBrush or QColor to achieve this?



  • @Faruq

    Hi everyone, I have solved it. So instead of my 1st post entry. I decided to use QColor to replace the Qt::LALALA where LALALA is the certain fixed range of colors as shown in the documentation.

       ui->TestQLCD->setSegmentStyle(QLCDNumber::Filled)
       ui->TestQLCD->setPalette(QColor(255,165,0,255));
    

    Do take note that the transparency is at the last digit ( 0 = full transparentcy while 255 is the full opaque)

    Whatever it is i encountered a puzzled response when i input
    ui->TestQLCD->setSegmentStyle(QLCDNumber::Filled);
    QColor c1=(255,165,0,255);
    ui->TestQLCD->setPalette(c1);

    It became blue/Dark blue no matter what number I tried. Puzzling but worth for others to know. Hope It is useful to the new sheeps like myself. :)


Log in to reply