PDA

View Full Version : Backgroundcolor QLCDNumber in Windows?



Teuniz
28th August 2006, 13:16
I use a QLCDNumber and I changed the color of the background like this:


lCDNumber1 = new QLCDNumber(myobjectDialog);
lCDNumber1->setGeometry(QRect(240, 810, 130, 40));
lCDNumber1->setLineWidth(1);
lCDNumber1->setSmallDecimalPoint(FALSE);
lCDNumber1->setNumDigits(7);
lCDNumber1->setSegmentStyle(QLCDNumber::Flat);
lCDNumber1->setProperty("value", 0);

lcdpalette = new QPalette;
lcdpalette->setColor(QPalette::Background, QColor(170, 255, 0));
lcdpalette->setColor(QPalette::Base, QColor(170, 255, 0));
lcdpalette->setColor(QPalette::AlternateBase, QColor(170, 255, 0));
lCDNumber1->setPalette(*lcdpalette);


In Linux it works ok, but in Windows XP the backgroundcolor of the QLCDNumber
is lightgrey instead of green. I changed the style to Plastique with:


app.setStyle(new QPlastiqueStyle);

this changed the style to plastic in Windows XP but I still can not change the
backgroundcolor of QLCDNumber.

What do I need to do to get this working in Windows XP?

Regards, Teuniz

jpn
29th August 2006, 09:59
Have you tried?


lCDNumber1->setAutoFillBackground(true);

Teuniz
30th August 2006, 11:51
lCDNumber1->setAutoFillBackground(true); does not work :(

mainwindow.cpp: In constructor ‘UI_Mainwindow::UI_Mainwindow()’:
mainwindow.cpp:246: error: ‘class QLCDNumber’ has no member named ‘setAutoFillBackground

jpn
30th August 2006, 13:32
mainwindow.cpp:246: error: ‘class QLCDNumber’ has no member named ‘setAutoFillBackground
Are you using Qt 4.0? The function was introduced in 4.1. I strongly suggest you to update to a recent version of Qt..

Teuniz
30th August 2006, 15:09
You are right, my QT version in Linux is 4.0 and it doesn't recognize this function.
I switched to Windows and now the fucntion is recognized because this version is 4.1.

Now the LCDNumber has the right backgroundcolor :)

Many thanks!